diff options
| author | JacobAKnox <[email protected]> | 2021-10-27 20:09:10 -0700 |
|---|---|---|
| committer | JacobAKnox <[email protected]> | 2021-10-27 20:09:10 -0700 |
| commit | 8ff4d236298feb927b7d838ac9f5d66c849ba502 (patch) | |
| tree | 49f31c1078cb753255b0d3f36762509e92e95e98 /9c/MultipleFiles/Student.cpp | |
| parent | 9b finished (diff) | |
| download | cst116-lab5-jacobaknox-8ff4d236298feb927b7d838ac9f5d66c849ba502.tar.xz cst116-lab5-jacobaknox-8ff4d236298feb927b7d838ac9f5d66c849ba502.zip | |
9c finished
Diffstat (limited to '9c/MultipleFiles/Student.cpp')
| -rw-r--r-- | 9c/MultipleFiles/Student.cpp | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/9c/MultipleFiles/Student.cpp b/9c/MultipleFiles/Student.cpp new file mode 100644 index 0000000..b5f744e --- /dev/null +++ b/9c/MultipleFiles/Student.cpp @@ -0,0 +1,85 @@ +#include <iostream> +#include "Student.h" + +using namespace std; + +void GetInputs(float scores[], int size) +{ + for (int i = 0; i < size; i++) + { + cout << "Enter score #" << i + 1 << " of " << size << ": "; + cin >> scores[i]; + } +} + +void GetCounts(float scores[], char grades[], int counts[], int sizeS) +{ + for (int i = 0; i < sizeS; i++) + { + if (scores[i] >= 90) + { + grades[i] = 'A'; + counts[0]++; + } + else if (scores[i] >= 80) + { + grades[i] = 'B'; + counts[1]++; + } + else if (scores[i] >= 70) + { + grades[i] = 'C'; + counts[2]++; + } + else if (scores[i] >= 60) + { + grades[i] = 'D'; + counts[3]++; + } + else + { + grades[i] = 'F'; + counts[4]++; + } + } +} + +int CalcAvg(float scores[], int size) +{ + float avg = 0, tot = 0; + + for (int i = 0; i < size; i++) + { + tot += scores[i]; + } + + avg = tot / size; + + return avg; +} + +void Output(float scores[], char grades[], int counts[], int avg, int sizeS, int sizeC) +{ + for (int i = 0; i < sizeS; 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 < sizeC; i++) + { + + if (i != 4) + { + letter = 65 + i; + } + else + { + letter = 70; + } + + cout << "There were " << counts[i] << letter << "'s.\n"; + } +} |