diff options
| author | JacobAKnox <[email protected]> | 2021-10-27 19:09:48 -0700 |
|---|---|---|
| committer | JacobAKnox <[email protected]> | 2021-10-27 19:09:48 -0700 |
| commit | 122d12f124c17191a188fd58f2c4b0bbefe6e7ae (patch) | |
| tree | 6ccd9f1b5989b4877dda33a2ed57a9d844229917 /10.5/10.5.cpp | |
| parent | Add online IDE url (diff) | |
| download | cst116-lab5-jacobaknox-122d12f124c17191a188fd58f2c4b0bbefe6e7ae.tar.xz cst116-lab5-jacobaknox-122d12f124c17191a188fd58f2c4b0bbefe6e7ae.zip | |
5.9a complete
Diffstat (limited to '10.5/10.5.cpp')
| -rw-r--r-- | 10.5/10.5.cpp | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/10.5/10.5.cpp b/10.5/10.5.cpp new file mode 100644 index 0000000..065bcf3 --- /dev/null +++ b/10.5/10.5.cpp @@ -0,0 +1,80 @@ +// 10.5.cpp : This file contains the 'main' function. Program execution begins and ends there. +// Written by Jacob Knox +// + + +#include <iostream> + +using namespace std; + +const int NUM_SCORES = 10; +const int NUM_GRADES = 5; + +int main() +{ + float scores[NUM_SCORES] = {}; + char grades[NUM_SCORES] = {}; + int counts[NUM_GRADES] = {0, 0, 0, 0, 0}; + float score = 0, tot = 0, avg = 0; + + for (int i = 0; i < NUM_SCORES; i++) + { + cout << "Enter score #" << i + 1 << " of " << NUM_SCORES << ": "; + cin >> score; + + scores[i] = score; + tot += score; + + if (score >= 90) + { + grades[i] = 'A'; + counts[0]++; + } + else if (score >= 80) + { + grades[i] = 'B'; + counts[1]++; + } + else if (score >= 70) + { + grades[i] = 'C'; + counts[2]++; + } + else if (score >= 60) + { + grades[i] = 'D'; + counts[3]++; + } + else + { + grades[i] = 'F'; + counts[4]++; + } + } + + avg = tot / (float)NUM_SCORES; + + for (int i = 0; i < NUM_SCORES; i++) + { + cout << "The " << i + 1 << " student recived a " << scores[i] << "% and got a(n) " << grades[i] << ".\n"; + } + + cout << "The average score is: " << avg << "%.\n"; + + char letter; + for (int i = 0; i < NUM_GRADES; i++) + { + + if (i != 4) + { + letter = 65 + i; + } + else + { + letter = 70; + } + + cout << "There were " << counts[i] << letter << "'s.\n"; + } + +}
\ No newline at end of file |