Question: Please complete the below C++ code as instructions: Most of the program is written. However, you need to create the functionality of taking the whole

Please complete the below C++ code as instructions:

Most of the program is written. However, you need to create the functionality of taking the whole gradebook and finding the average across all students (rows) for each of the assignments (columns).

Hint: if you have nested loops to traverse the gradebook, you want to go through each ROW (student) before going onto the next COLUMN (assignments). Usually you've done it the other way around, but since we are averaging each column, the order needs to be different.

#include

#include #include using namespace std;

//Global constants... const int MAX_EXERCISES = 10; const int MAX_STUDENTS = 5;

//Function prototypes... vector < vector > fillGradebook(int,int); int getNum(string,int); void display(vector );

//Main program... int main() { int exercises=0; int students=0; vector < vector > gradebook; vector avgGrade;

exercises = getNum("exercises",MAX_EXERCISES); students = getNum("students",MAX_STUDENTS); gradebook = fillGradebook(students,exercises); avgGrade = averageAssignment( gradebook ); // <-- IMPLEMENT FUNCTION FOR THIS display(avgGrade);

return 0; }

vector < vector > fillGradebook(int students, int exercises) { vector < vector > grades; //make row for each student grades.resize(students);

for(int student=0; student < students; student++ ) { cout<<"Enter student "<<(student+1)<<"'s " <>grade; grades[student].push_back(grade); } } return grades; }

int getNum(string name,int maximum) { int count = 0; do { cout<<"How many "<>count; if( count < 1 || count > maximum ) { cout<<"ERROR: Must be between 1-"< maximum); return count; }

void display(vector grades) { cout<<"===AVERAGE GRADES PER ASSIGNMENT=== "; for(int i = 0; i < grades.size(); i++) { cout<

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!