Question: Modify 1st code so that the instructor can enter up to 5 test scores per student. The class roster should include the average test score
Modify 1st code so that the instructor can enter up to 5 test scores per student. The class roster should include the average test score for each student as well as the overall grade. Update the class statistics to include the average score for each of test. You must create a class called student that has the following data members. First Name Last Name An array or a vector that contains the test scores. All class data members must be private or protected. Separate the class interface from the class implementation and use include guards.
Note: //I'm attaching the screenshots of my last code here. //Modify that code and pass it on please.
#include
class Student { private: string name; float testScore; char grade; public: void setName(string n) { name = n; } void settestScore(float score) { testScore = score; } void setGrade() { if (testScore >= 90) grade = 'A'; else if (testScore >= 80) grade = 'B'; else if (testScore >= 70) grade = 'C'; else if (testScore >= 60) grade = 'D'; else grade = 'F'; } string getName(){ return name; } float gettestScore(){ return testScore; } char getgrade() { return grade; } }; void display(Student students[], int t) { if (t == 0) return; cout << left; cout << setw(9) << "Name" << setw(13) << "Test Score" << setw(8) << "Grade "; cout << setw(8) << "=====" << setw(12) << "==========" << setw(7) << "==== "; float maxi, mini, average, sum = 0; maxi = mini = students[0].gettestScore(); for (int i = 0; i < t; i++) { sum += students[i].gettestScore(); cout << setw(8) << students[i].getName() << setw(12) << students[i].gettestScore() << setw(7) << students[i].getgrade() << " "; maxi = max(maxi, students[i].gettestScore()); mini = min(mini, students[i].gettestScore()); } average = sum / (float)t; cout << " <<<<<<<<<<<
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
