aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWiserJ <[email protected]>2021-10-27 15:31:02 -0700
committerWiserJ <[email protected]>2021-10-27 15:31:02 -0700
commit77d64a760e3c8fffe875de13169e6cbf729f9db4 (patch)
treecbfceb0dd3d0f8dd50af7cf8ebf61d75982d10bb
parentworking 2/4 (diff)
downloadcst116-lab5-jeffwoit-77d64a760e3c8fffe875de13169e6cbf729f9db4.tar.xz
cst116-lab5-jeffwoit-77d64a760e3c8fffe875de13169e6cbf729f9db4.zip
4/4 test
-rw-r--r--CST116F2021-Lab5/CST116F2021-Lab5.cpp36
1 files 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