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 #include using namespace std;

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 << " <<<<<<<<<<<>>>>>>>>>> "; cout << "Number of students in the class: " << t << endl; cout << "Class Average: " << average << endl; cout << "Maximum Test Score: " << maxi << endl; cout << "Minimum Test Score: " << mini << endl; } int main() { int t; cout << "What is the total number of students in your class?" << endl; cin >> t; Student students[40]; for (int i = 0; i < t; i++) { string name; float score; cout << "Please enter student " << (i + 1) << " name: "; cin >> name; students[i].setName(name); cout << "Please enter student " << (i+1) << " testScore: "; cin >> score; students[i].settestScore(score); students[i].setGrade(); } display(students, t); return 0; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!