Exercise 2: Students Average Marks
In this exercise, you have to calculate a student's average marks using the concept of Classes
We'll cover the following
Problem Statement
Write a C# class called student
with
-
private
member variables:mark1
of typefloat
-
mark2
of typefloat
And methods:
-
Get_Marks(int marknumber)
, a function which should returnmark1
ifmarknumber
equals 1 andmark2
otherwise. -
calc_average()
function should take the two marks entered and return their average.
Also define two constructors:
- A default constructor that takes no parameters and initializes the values to zeros.
- A constructor that takes the two
private
variables and sets them to given values.
Get hands-on with 1400+ tech skills courses.