Question: // Roster.cpp : Defines the entry point for the console application. // #include #include #include using namespace std; int main() { string courses[] = {Math,Science,English};

// Roster.cpp : Defines the entry point for the console application.

//
#include
#include
#include
using namespace std;
int main()
{
string courses[] = {"Math","Science","English"};
string students[] = {"Joe","Jay"};
const int STUDENT_COUNT = sizeof(students) / sizeof(students[0]);
const int COURSE_COUNT = sizeof(courses) / sizeof(courses[0]);
short grades[COURSE_COUNT][STUDENT_COUNT];
float courseAverage[COURSE_COUNT] = { 0.0 };
for (size_t i = 0; i < COURSE_COUNT; i++){
cout << "Input grades for course: " << courses[i] << endl;
for (size_t j = 0; j < STUDENT_COUNT; j++){
cout << "\t" << students[j] << ": ";
cin >> grades[i][j];
}
}
for (size_t i = 0; i < COURSE_COUNT; i++) {
courseAverage[i] = 0.0;
for (size_t j = 0; j < STUDENT_COUNT; j++) {
courseAverage[i] += grades[i][j];
}
courseAverage[i] /= STUDENT_COUNT;
}
for (size_t i = 0; i < COURSE_COUNT; i++) {
for (size_t j = 0; j < STUDENT_COUNT; j++) {
cout << setw(6) << grades[i][j];
}
cout << endl;
}
cout << "The Averages are: " << endl;
for (size_t i = 0; i < COURSE_COUNT; i++)
{
cout << setw(15) << courses[i] << setw(8)
<< setprecision(2) << fixed << courseAverage[i] << endl;
}
return 0;

}

Given the code we studied last Friday, modify it so it shows the average of each course and each student in a nicely formatted table.

 Math English PE Average John 80 90 85 85.00 Peter 100 90 90 93.33 -------------------------------------- Average 90.00 90.00 87.50 89.17 

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!