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
Problem Statement
Write a C++ class called student
with
-
private
member variables:-
name
(string
type) -
mark1
andmark2
(float type)
-
And member functions:
-
Get_Marks(int marknumber)
, a function which should returnmark1
ifmarknumber
equals 1 andmark2
otherwise. -
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