Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Expert Oracle9i Database Administration

Authors: Sam R. Alapati

1st Edition

1590590228, 978-1590590225

More Books

Students also viewed these Databases questions

Question

The normal distribution is symmetrical. What does this mean?

Answered: 1 week ago

Question

Working with other project stakeholders for support.

Answered: 1 week ago

Question

What is the Definition for Third Normal Form?

Answered: 1 week ago

Question

Provide two examples of a One-To-Many relationship.

Answered: 1 week ago