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 type float
  • mark2 of type float

And methods:

  • Get_Marks(int marknumber), a function which should return mark1 if marknumber equals 1 and mark2 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 1200+ tech skills courses.