Solution Review: Calculate the Student's Total Marks
This review provides a detailed analysis to solve the 'Calculate the Student's Total Marks' challenge.
We'll cover the following...
Solution
Press + to interact
class Student {//fieldsprivate string _name;private double _physicsMarks;private double _chemistryMarks;private double _biologyMarks;//propertiespublic string Name {get {return this._name;}}public double PhysicsMarks {get {return this._physicsMarks;}}public double ChemistryMarks {get {return this._chemistryMarks;}}public double BiologyMarks {get {return this._biologyMarks;}}// Parameterized constructorpublic Student(string name, double phy, double chem, double bio) {this._name = name;this._physicsMarks = phy;this._chemistryMarks = chem;this._biologyMarks = bio;}public double TotalObtained() {double totalMarks = PhysicsMarks + ChemistryMarks + BiologyMarks;return totalMarks;}public double Percentage() {return (TotalObtained()/300) * 100;}}class Demo {public static void Main(string[] args) {Student john = new Student("John", 75, 75, 90);Console.WriteLine("Total marks obtained: " + john.TotalObtained());Console.WriteLine("Percentage obtained:" + john.Percentage());Console.WriteLine("Physics Marks:" + john.PhysicsMarks);}}
...