From 77d64a760e3c8fffe875de13169e6cbf729f9db4 Mon Sep 17 00:00:00 2001 From: WiserJ Date: Wed, 27 Oct 2021 15:31:02 -0700 Subject: 4/4 test --- CST116F2021-Lab5/CST116F2021-Lab5.cpp | 36 ++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/CST116F2021-Lab5/CST116F2021-Lab5.cpp b/CST116F2021-Lab5/CST116F2021-Lab5.cpp index c13da24..1e5729c 100644 --- a/CST116F2021-Lab5/CST116F2021-Lab5.cpp +++ b/CST116F2021-Lab5/CST116F2021-Lab5.cpp @@ -7,20 +7,23 @@ using namespace std; const int NUM_SCORES = 10; const int NUM_STUD = 5; +const int NUM_GRADE = 5; int main() { float currStudent[NUM_SCORES]{ 0.0 }; + char Grade[NUM_SCORES]; + int numGrade[NUM_GRADE]; + float avg = 0.0; - + //Loop for storing scores to array for (int i = 0; i < NUM_SCORES; i++) { cout << "Enter score #" << i + 1 << " of " << NUM_SCORES << ": "; cin >> currStudent[i]; } - char Grade[NUM_SCORES]; - + //Loop for comparing scores to letter grade then storing to another array for (int i = 0; i < NUM_SCORES; i++) { if (currStudent[i] >= 92.0) @@ -34,8 +37,31 @@ int main() else Grade[i] = 'F'; - cout << "\nTest #" << i + 1 << " received grade " << Grade[i]; - + cout << "\nTest #" << i + 1 << " scored " << currStudent[i] << " and received grade " << Grade[i]; } + //Calc class average + for (int i = 0; i < NUM_SCORES; i++) + { + avg += currStudent[i]; + } + + avg /= NUM_SCORES; + + cout << "\nThe class average for " << NUM_SCORES << " scores is " << avg; + + //Loop for counting number of each letter grade + for (int i = 0; i < NUM_SCORES; i++) + { + if (Grade[i] == A) + numGrade[0] += 1; + else if (Grade[i] == B) + numGrade[1] += 1; + else if (Grade[i] == C) + numGrade[2] += 1; + else if (Grade[i] == D) + numGrade[3] += 1; + else + numGrade[4] += 1; + } } \ No newline at end of file -- cgit v1.2.3