Question: Write a C++ program that asks the user the grades of 3 classes each with 10 students. The program then stores these grades in a
Write a C++ program that asks the user the grades of 3 classes each with 10 students. The program then stores these grades in a 2D array and displays them. The program then outputs the lowest grade, highest grade, and average for each class. User-defined functions should be used for getting the lowest grade, highest grade, and average grade of each class.
here is my progress so far, pls help
#include
using namespace std;
int main( ) { int sum = 0; int avg = 0; int low = 999999; int high = 0; int array[11];
cout << "Please enter 10 scores of class 1" << endl; cout << " - - - - - - - - - - - " << endl;
for (int i = 0; i < 10; i++) { cout << "Please enter a score: "; cin >> array[i]; //sum+=array[i]; }
for (int i = 0; i < 10; i++) { sum += array[i];
if (array[i] < low) { low = array[i]; }
if (array[i] > high) { high = array[i]; } } avg = sum/10;
for (int i = 0; i < 10; i++) { cout << array[i] << endl; }
cout << "The lowest score is: " << low << endl; cout << "The highest score is: " << high << endl; cout << "The average score is: " << avg << endl; cout << "Please enter 10 scores of class 2" << endl; cout << " - - - - - - - - - - - " << endl;
for (int i = 0; i < 10; i++) { cout << "Please enter a score: "; cin >> array[i]; //sum+=array[i]; }
for (int i = 0; i < 10; i++) { sum += array[i];
if (array[i] < low) { low = array[i]; }
if (array[i] > high) { high = array[i]; } } avg = sum/10;
for (int i = 0; i < 10; i++) { cout << array[i] << endl; }
cout << "The lowest score is: " << low << endl; cout << "The highest score is: " << high << endl; cout << "The average score is: " << avg << endl;
cout << "Please enter 10 scores of class 3" << endl; cout << " - - - - - - - - - - - " << endl;
for (int i = 0; i < 10; i++) { cout << "Please enter a score: "; cin >> array[i]; //sum+=array[i]; }
for (int i = 0; i < 10; i++) { sum += array[i];
if (array[i] < low) { low = array[i]; }
if (array[i] > high) { high = array[i]; } } avg = sum/10;
for (int i = 0; i < 10; i++) { cout << array[i] << endl; }
cout << "The lowest score is: " << low << endl; cout << "The highest score is: " << high << endl; cout << "The average score is: " << avg << endl; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
