diff options
Diffstat (limited to 'CST116F2021-Lab5/CST116F2021-Lab5.cpp')
| -rw-r--r-- | CST116F2021-Lab5/CST116F2021-Lab5.cpp | 100 |
1 files changed, 100 insertions, 0 deletions
diff --git a/CST116F2021-Lab5/CST116F2021-Lab5.cpp b/CST116F2021-Lab5/CST116F2021-Lab5.cpp index ff0d297..cce1779 100644 --- a/CST116F2021-Lab5/CST116F2021-Lab5.cpp +++ b/CST116F2021-Lab5/CST116F2021-Lab5.cpp @@ -6,7 +6,107 @@ Austin Guertin 1. +#include <iostream> +#include <string> +using namespace std; + +int main() + +{ + int scores[10]; + + char grades[10]; + + cout << "Enter numeric grades separated by spaces:"; + + for (int i = 0; i < 10; i++) + { + cin >> scores[i]; + } + + for (int i = 0; i < 10; i++) + + { + if (scores[i] >= 92) + + grades[i] = 'A'; + + else if (scores[i] >= 84) + + grades[i] = 'B'; + + else if (scores[i] >= 75) + + grades[i] = 'C'; + + else if (scores[i] >= 65) + + grades[i] = 'D'; + + else + + grades[i] = 'F'; + } + + double avg = 0; + + int aCount = 0; + + int bCount = 0; + + int cCount = 0; + + int dCount = 0; + + int fCount = 0; + + for (int i = 0; i < 10; i++) + + { + avg += scores[i]; + + if (grades[i] == 'A') + + aCount++; + + else if (grades[i] == 'B') + + bCount++; + + else if (grades[i] == 'C') + + cCount++; + + else if (grades[i] == 'D') + + dCount++; + + else + + fCount++; + } + + avg = avg / 10; + + for (int i = 0; i < 10; i++) + + { + cout << "Score " << (i + 1) << ": " << scores[i] << ", and the grade is a(n) " << grades[i] << endl; + } + + cout << "\nAverage of all the scores is: " << avg << " \n\n"; + + cout << "\nNumber of A's is/are: " << aCount << " \n"; + + cout << "\nNumber of B's is/are: " << bCount << " \n"; + + cout << "\nNumber of C's is/are: " << cCount << " \n"; + + cout << "\nNumber of D's is/are: " << dCount << " \n"; + + cout << "\nNumber of F's is/are: " << fCount << " \n\n"; +} |