Challenge 3: Analyzing the Performance of Students

In this exercise, you have to analyze a student's performance using the concept of classes

Problem Statement

Implement a class, Student, that has four fields with properties and two methods. This challenge is designed to test your understanding of following good OOP practices. The problem can be broken down into three tasks:

Task 1

  • The properties should only have the get block defined for the relative fields, you can skip the set block.
  • Implement a parameterized constructor to initialize the values of four properties: Name, PhysicsMarks, ChemistryMarks, and, BioMarks.

Task 2

Implement a method, TotalObtained(), in the Student class that calculates and returns the total marks of a student.

Task 3

Using the TotalObtained() method, implement another method, Percentage(), in the Student class that calculates the percentage of the student’s marks. Assume that the total marks of each subject are 100. So, the combined marks of three subjects are 300.

Below is the formula for calculating the percentage:

Sample Input

Student john = new Student("John", 75, 75, 90)

Sample Output

john.TotalObtained() = 240
john.Percentage() = 80
john.PhysicsMarks = 75

Get hands-on with 1400+ tech skills courses.