aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWiserJ <[email protected]>2021-10-27 15:51:12 -0700
committerWiserJ <[email protected]>2021-10-27 15:51:12 -0700
commit287105b4899810a5c6dbad978b0ef71938d5879a (patch)
tree9b18f6e5e5edcc21e3a35ad4e6f5dcf805deeb39
parent10-5 finished (diff)
downloadcst116-lab5-jeffwoit-287105b4899810a5c6dbad978b0ef71938d5879a.tar.xz
cst116-lab5-jeffwoit-287105b4899810a5c6dbad978b0ef71938d5879a.zip
p.253 start
-rw-r--r--CST116F2021-Lab5/CST116F2021-Lab5.cpp103
1 files changed, 98 insertions, 5 deletions
diff --git a/CST116F2021-Lab5/CST116F2021-Lab5.cpp b/CST116F2021-Lab5/CST116F2021-Lab5.cpp
index 2d86908..9cea67c 100644
--- a/CST116F2021-Lab5/CST116F2021-Lab5.cpp
+++ b/CST116F2021-Lab5/CST116F2021-Lab5.cpp
@@ -5,6 +5,11 @@
using namespace std;
+void GetScores(float cStu[]);
+void CheckGrade(char cGrade[]);
+float calcAvg(float avg);
+void CountScores(int nGrade[]);
+
const int NUM_SCORES = 10;
const int NUM_STUD = 5;
const int NUM_GRADE = 5;
@@ -15,14 +20,28 @@ int main()
char Grade[NUM_SCORES];
int numGrade[NUM_GRADE]{ 0 };
float avg = 0.0;
-
+
+ GetScores(currStudent);
+ CheckGrade(Grade);
+ calcAvg(avg);
+ CountScores(numGrade);
+
+
+ return 0;
+}
+
+void GetScores(float score_input[])
+{
//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];
+ cin >> score_input[i];
}
+}
+void CheckGrade(char grade_output[])
+{
//Loop for comparing scores to letter grade then storing to another array
for (int i = 0; i < NUM_SCORES; i++)
{
@@ -39,7 +58,10 @@ int main()
cout << "\nTest #" << i + 1 << " scored " << currStudent[i] << " and received grade " << Grade[i];
}
-
+}
+
+float calcAvg(float avg)
+{
//Calc class average
for (int i = 0; i < NUM_SCORES; i++)
{
@@ -49,7 +71,10 @@ int main()
avg /= NUM_SCORES;
cout << "\n\nThe class average for " << NUM_SCORES << " scores is " << avg << endl;
+}
+void CountScores(int nGrade[])
+{
//Loop for counting number of each letter grade
for (int i = 0; i < NUM_SCORES; i++)
{
@@ -70,6 +95,74 @@ int main()
cout << "\nThe number of Grade C tests is: " << numGrade[2];
cout << "\nThe number of Grade D tests is: " << numGrade[3];
cout << "\nThe number of Grade F tests is: " << numGrade[4];
+}
- return 0;
-} \ No newline at end of file
+//p.247
+//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]{ 0 };
+// 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];
+// }
+//
+// //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)
+// Grade[i] = 'A';
+// else if (currStudent[i] >= 84.0)
+// Grade[i] = 'B';
+// else if (currStudent[i] >= 75.0)
+// Grade[i] = 'C';
+// else if (currStudent[i] >= 65.0)
+// Grade[i] = 'D';
+// else
+// Grade[i] = 'F';
+//
+// 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 << "\n\nThe class average for " << NUM_SCORES << " scores is " << avg << endl;
+//
+// //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;
+// }
+//
+// cout << "\nThe number of Grade A tests is: " << numGrade[0];
+// cout << "\nThe number of Grade B tests is: " << numGrade[1];
+// cout << "\nThe number of Grade C tests is: " << numGrade[2];
+// cout << "\nThe number of Grade D tests is: " << numGrade[3];
+// cout << "\nThe number of Grade F tests is: " << numGrade[4];
+//
+// return 0;
+//} \ No newline at end of file