Question
We would like to develop a class student to be used to find the average mark for a number of students in one section. The
We would like to develop a class student to be used to find the average mark for a number of students in one section. The class has data members name (of type string), mark (of type int), static data members count (of type int to keep track of the number of objects instantiated from class student), and totalMarks (of type int to keep track of the total number of students in all declared students). The class student also has any needed set(), get(), print() member functions, a parameterized constructor with default values, and a destructor. The class has a member function getCount( ) to return count, a member function getTotalMarks( ) to return total marks, a member function avgStudents( ) which computes the average mark of all the declared students. The destructor should print the values of count and totalMarks.\ \ Implement the set() function, a parameterized constructor with default values, and a destructor of the class in the file studentImp.cpp, the class in the file student.h, and the driver in the file student.cpp. Use const whenever needed to enforce the principle of least privilege. \ \ The following driver produces the given sample of input/output:\ \ int main()\ {\ string studentName;\ int studentMark;\ \ cout << setiosflags(ios::fixed | ios::showpoint) << setprecision(1);\ \ student A("Omar", 75);\ A.print();\ cout << "Number of students is: " << student::getCount() \ << " and total maks is: " << student::getTotalMarks() << endl;\ \ student B("Ali", 89);\ B.print();\ cout << "Number of students is: " << student::getCount() \ << " and total maks is: " << student::getTotalMarks() << endl;\ \ student C("Hassan", 45);\ C.print();\ cout << "Number of students is: " << student::getCount() \ << " and total maks is: " << student::getTotalMarks() << endl;\ \ student D;\ cout << "Enter the student name, and mark: ";\ cin >> studentName >> studentMark;\ D.set(studentName, studentMark);\ D.print();\ cout << "Number of students is: " << student::getCount() \ << " and total maks is: " << student::getTotalMarks() << endl;\ \ cout << "Average students mark is: " << student::avgStudents() << endl << endl;\ \ return 0;\ }\ \ \ The implementations of the following functions are given:\ \ \ int student::count = 0;\ int student::totalMarks = 0;\ \ \ void student::get(string& studentName, int& studentMark) const\ {\ studentName = name;\ studentMark = mark;\ }\ \ \ int student::getCount()\ {\ return count;\ }\ \ \ int student::getTotalMarks()\ {\ return totalMarks;\ }\ \ \ double student::avgStudents() \ {\ return totalMarks/ count;\ }\ \ \ void student::print() const\ {\ cout << name << " mark is: " << mark << endl;\ }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started