Assignment

Write your question here.

Create a class called student. This class contains data members for name, roll no, and CGPA of a student.
Provide a no-argument constructor for initializing the data members to some fixed value.
Provide a 2-argument constructor to initialize the data members to the values sent from the calling function.
Provide separate setter functions for setting each data member. These functions should take the values from user at run-time.
Provide separate getter functions for each data member. The getter functions should return the value of the corresponding fields.
Create a function display that displays all the information to user.
Let us suppose that we want to keep information about average CGPA of students in a particular department. Make appropriate changes in the class to handle this extra information (Hint: provide static data members for average CGPA and no of students and set the values for these members in constructor). Provide a static function to display this additional information.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <iostream>
#include <cctype>
#include <limits>

int main()
{
   std::cout << "Do you want someone to do all the work for you? ";
   char answer{};
   std::cin >> answer;

   std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');

   if (std::toupper(answer) == 'Y' ) { std::cout << "Post it in the Jobs section.\n"; }

   else { std::cout << "Show what you have coded so far.\n"; }

   std::cout << "Good luck.\n";
}
Topic archived. No new replies allowed.