Challenge 2: Calculate Student's Total Marks
In this exercise, you have to calculate a student's total marks using the concept of Classes
We'll cover the following...
We'll cover the following...
Problem Statement
Write a C++ class called student with
-
privatemember variables:-
name(stringtype) -
mark1andmark2(float type)
-
And member functions:
-
Get_Marks(int marknumber), a function which should returnmark1ifmarknumberequals 1 andmark2otherwise. -
calc_total()function should take the two marks entered and return their sum.
Also define two constructors:
- A default constructor that takes no parameters and initializes the values to zeros and
null. - A constructor that takes the three variables and sets them to given values.
Input
Name of student, marks in first and second test
Output
Sum of both marks
Sample Input
("Jack", 60, 70)
Sample Output
GetMarks(1) => 60
GetMarks(2) => 70
calc_total() => 130