Problem statement
Implement a class - Student - that has four properties and two methods. All these attributes (properties and methods) should be public. This problem can be broken down into three tasks.
Task 1
Implement a constructor to initialize the values of four properties: name, phy, chem, and bio.
Task 2
Implement a method – totalObtained – in the Student class that calculates total marks of a student.
Sample properties
name = Mark
phy = 80
chem = 90
bio = 40
Sample method output
obj1.Total()=210
Task 3
Using the totalObtained method, implement another method, percentage, in the Student class that calculates the percentage of students marks. Assume that the total marks of each subject are 100. The combined marks of three subjects are 300.
The formula for calculating the percentage is given below.
100
TotalMarks
MarksObtained
×100
Sample input
phy = 80
chem = 90
bio = 40
Sample output
70
Coding exercise
Design a step-by-step algorithm before jumping to the implementation. This problem is designed for your practice, so initially, try to solve it on your own. If you get stuck, you can always refer to the solution provided in next lesson.