Finding the average across all students


Complete the below c++ code based on instructions below:

You need to create the functionality of taking the whole and finding the average across all students (rows) for each of the assignments (columns).

#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 "
<for(int exercise=0; exercise < exercises; exercise++)
{
//add a column for each student's grade
double grade;
cin>>grade;
grades[student].push_back(grade);
}
}
return grades;
}
int getNum(string name,int maximum)
{
int count = 0;
do
{
cout<<"How many "<cin>>count;
if( count < 1 || count > maximum )
{
cout<<"ERROR: Must be between 1-"<}
}while( count < 1 || count > maximum);
return count;
}
void display(vector grades)
{
cout<<"===AVERAGE GRADES PER ASSIGNMENT===\n";
for(int i = 0; i < grades.size(); i++)
{
cout<}
cout<}

Solution Preview :

Prepared by a verified Expert
C/C++ Programming: Finding the average across all students
Reference No:- TGS01960662

Now Priced at $25 (50% Discount)

Recommended (90%)

Rated (4.3/5)