aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWiserJ <[email protected]>2021-10-27 16:20:54 -0700
committerWiserJ <[email protected]>2021-10-27 16:20:54 -0700
commita68f14de3b27ba6858c2f2557235f79f2129645d (patch)
tree2aa54b19a12c7c7d8f7b67cd01d8dac61846d3dd
parentp.253 start (diff)
downloadcst116-lab5-jeffwoit-a68f14de3b27ba6858c2f2557235f79f2129645d.tar.xz
cst116-lab5-jeffwoit-a68f14de3b27ba6858c2f2557235f79f2129645d.zip
10.6 final
-rw-r--r--CST116F2021-Lab5/CST116F2021-Lab5.cpp73
-rw-r--r--CST116F2021-Lab5/Header1.h1
-rw-r--r--CST116F2021-Lab5/Source1.cpp0
3 files changed, 39 insertions, 35 deletions
diff --git a/CST116F2021-Lab5/CST116F2021-Lab5.cpp b/CST116F2021-Lab5/CST116F2021-Lab5.cpp
index 9cea67c..2b9258b 100644
--- a/CST116F2021-Lab5/CST116F2021-Lab5.cpp
+++ b/CST116F2021-Lab5/CST116F2021-Lab5.cpp
@@ -2,13 +2,14 @@
//
#include <iostream>
+//#include "Header1.h"
using namespace std;
-void GetScores(float cStu[]);
-void CheckGrade(char cGrade[]);
-float calcAvg(float avg);
-void CountScores(int nGrade[]);
+void GetScores(float []);
+void CheckGrade(float [], char []);
+float calcAvg(float [], float avg);
+void CountScores(char [], int []);
const int NUM_SCORES = 10;
const int NUM_STUD = 5;
@@ -22,9 +23,9 @@ int main()
float avg = 0.0;
GetScores(currStudent);
- CheckGrade(Grade);
- calcAvg(avg);
- CountScores(numGrade);
+ CheckGrade(currStudent, Grade);
+ calcAvg(currStudent, avg);
+ CountScores(Grade, numGrade);
return 0;
@@ -40,61 +41,63 @@ void GetScores(float score_input[])
}
}
-void CheckGrade(char grade_output[])
+void CheckGrade(float score_input[], char grade_output[])
{
//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';
+ if (score_input[i] >= 92.0)
+ grade_output[i] = 'A';
+ else if (score_input[i] >= 84.0)
+ grade_output[i] = 'B';
+ else if (score_input[i] >= 75.0)
+ grade_output[i] = 'C';
+ else if (score_input[i] >= 65.0)
+ grade_output[i] = 'D';
else
- Grade[i] = 'F';
+ grade_output[i] = 'F';
- cout << "\nTest #" << i + 1 << " scored " << currStudent[i] << " and received grade " << Grade[i];
+ cout << "\nTest #" << i + 1 << " scored " << score_input[i] << " and received grade " << grade_output[i];
}
}
-float calcAvg(float avg)
+float calcAvg(float score_input[], float avg)
{
//Calc class average
for (int i = 0; i < NUM_SCORES; i++)
{
- avg += currStudent[i];
+ avg += score_input[i];
}
avg /= NUM_SCORES;
cout << "\n\nThe class average for " << NUM_SCORES << " scores is " << avg << endl;
+
+ return avg;
}
-void CountScores(int nGrade[])
+void CountScores(char grade_output[], int nGrade[])
{
//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;
+ if (grade_output[i] == 'A')
+ nGrade[0] += 1;
+ else if (grade_output[i] == 'B')
+ nGrade[1] += 1;
+ else if (grade_output[i] == 'C')
+ nGrade[2] += 1;
+ else if (grade_output[i] == 'D')
+ nGrade[3] += 1;
else
- numGrade[4] += 1;
+ nGrade[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];
+ cout << "\nThe number of Grade A tests is: " << nGrade[0];
+ cout << "\nThe number of Grade B tests is: " << nGrade[1];
+ cout << "\nThe number of Grade C tests is: " << nGrade[2];
+ cout << "\nThe number of Grade D tests is: " << nGrade[3];
+ cout << "\nThe number of Grade F tests is: " << nGrade[4];
}
//p.247
diff --git a/CST116F2021-Lab5/Header1.h b/CST116F2021-Lab5/Header1.h
new file mode 100644
index 0000000..6f70f09
--- /dev/null
+++ b/CST116F2021-Lab5/Header1.h
@@ -0,0 +1 @@
+#pragma once
diff --git a/CST116F2021-Lab5/Source1.cpp b/CST116F2021-Lab5/Source1.cpp
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/CST116F2021-Lab5/Source1.cpp