summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Schroeder <[email protected]>2021-10-29 11:42:00 -0700
committerBenjamin Schroeder <[email protected]>2021-10-29 11:42:00 -0700
commite4ecf5c0cca2e98299b3840528cdc5ac2599384c (patch)
tree481dadd7d869e4b0b04e5e59ad6901a06f831cb5
parentAdd online IDE url (diff)
downloadcst116-lab5-bensprogramma-e4ecf5c0cca2e98299b3840528cdc5ac2599384c.tar.xz
cst116-lab5-bensprogramma-e4ecf5c0cca2e98299b3840528cdc5ac2599384c.zip
Scores.h
CST1162021=Lab5_Schroeder.cpp ScoresFunctions.cpp RUN_CDT1162021_Scores_Scroeder.txt
-rw-r--r--CST116F2021-Lab5/CST116F2021-Lab5.cpp20
-rw-r--r--CST116F2021-Lab5/CST116F2021-Lab5.vcxproj6
-rw-r--r--CST116F2021-Lab5/CST116F2021-Lab5.vcxproj.filters10
-rw-r--r--CST116F2021-Lab5/CST116F2021-Lab5_Schroeder.cpp22
-rw-r--r--CST116F2021-Lab5/Scores.h14
-rw-r--r--CST116F2021-Lab5/ScoresFunctions.cpp80
-rw-r--r--RUN_CST1162021_Scores_Schroeder.txt37
7 files changed, 167 insertions, 22 deletions
diff --git a/CST116F2021-Lab5/CST116F2021-Lab5.cpp b/CST116F2021-Lab5/CST116F2021-Lab5.cpp
deleted file mode 100644
index e7591f7..0000000
--- a/CST116F2021-Lab5/CST116F2021-Lab5.cpp
+++ /dev/null
@@ -1,20 +0,0 @@
-// CST116F2021-Lab5.cpp : This file contains the 'main' function. Program execution begins and ends there.
-//
-
-#include <iostream>
-
-int main()
-{
- std::cout << "Hello World!\n";
-}
-
-// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
-// Debug program: F5 or Debug > Start Debugging menu
-
-// Tips for Getting Started:
-// 1. Use the Solution Explorer window to add/manage files
-// 2. Use the Team Explorer window to connect to source control
-// 3. Use the Output window to see build output and other messages
-// 4. Use the Error List window to view errors
-// 5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
-// 6. In the future, to open this project again, go to File > Open > Project and select the .sln file
diff --git a/CST116F2021-Lab5/CST116F2021-Lab5.vcxproj b/CST116F2021-Lab5/CST116F2021-Lab5.vcxproj
index 14ee2b7..2f149cc 100644
--- a/CST116F2021-Lab5/CST116F2021-Lab5.vcxproj
+++ b/CST116F2021-Lab5/CST116F2021-Lab5.vcxproj
@@ -139,7 +139,11 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup>
- <ClCompile Include="CST116F2021-Lab5.cpp" />
+ <ClCompile Include="CST116F2021-Lab5_Schroeder.cpp" />
+ <ClCompile Include="ScoresFunctions.cpp" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="Scores.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
diff --git a/CST116F2021-Lab5/CST116F2021-Lab5.vcxproj.filters b/CST116F2021-Lab5/CST116F2021-Lab5.vcxproj.filters
index c9f2fd4..3a47095 100644
--- a/CST116F2021-Lab5/CST116F2021-Lab5.vcxproj.filters
+++ b/CST116F2021-Lab5/CST116F2021-Lab5.vcxproj.filters
@@ -15,8 +15,16 @@
</Filter>
</ItemGroup>
<ItemGroup>
- <ClCompile Include="CST116F2021-Lab5.cpp">
+ <ClCompile Include="CST116F2021-Lab5_Schroeder.cpp">
<Filter>Source Files</Filter>
</ClCompile>
+ <ClCompile Include="ScoresFunctions.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="Scores.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
</ItemGroup>
</Project> \ No newline at end of file
diff --git a/CST116F2021-Lab5/CST116F2021-Lab5_Schroeder.cpp b/CST116F2021-Lab5/CST116F2021-Lab5_Schroeder.cpp
new file mode 100644
index 0000000..71d0927
--- /dev/null
+++ b/CST116F2021-Lab5/CST116F2021-Lab5_Schroeder.cpp
@@ -0,0 +1,22 @@
+// Lab5_Schroeder_TestScores.cpp : This file contains the 'main' function. Program execution begins and ends there.
+//
+//247 10.5 and 10.6 Learn by doing exercises
+
+//
+#include "Scores.h"
+
+
+int main()
+{
+ int gradeCounts[5]{ 0 };
+ float testScore[NUM_STUDENT]{ 0.0 };
+ char letterGrade[NUM_STUDENT]{ 'A' };
+
+
+ ReadScores(testScore);
+ LetterG(letterGrade, testScore, gradeCounts);
+ cout << "\n\n";
+ displayG(testScore, letterGrade, gradeCounts);
+ average(testScore);
+}
+
diff --git a/CST116F2021-Lab5/Scores.h b/CST116F2021-Lab5/Scores.h
new file mode 100644
index 0000000..a8254e6
--- /dev/null
+++ b/CST116F2021-Lab5/Scores.h
@@ -0,0 +1,14 @@
+#pragma once
+
+#include <iostream>
+using namespace std;
+
+const int NUM_SCORES = 1;
+const int NUM_STUDENT = 10;
+
+void ReadScores(float[]);
+void LetterG(char[], float[], int[]);
+void average(float[]);
+void displayG(float[], char[], int[]);
+
+
diff --git a/CST116F2021-Lab5/ScoresFunctions.cpp b/CST116F2021-Lab5/ScoresFunctions.cpp
new file mode 100644
index 0000000..3b7db0a
--- /dev/null
+++ b/CST116F2021-Lab5/ScoresFunctions.cpp
@@ -0,0 +1,80 @@
+
+#include "Scores.h"
+
+
+void ReadScores(float testScore[])
+{
+ cout << "Enter percent score of student: \n";
+
+ for (int i = 0; i < NUM_STUDENT; i++) // starting at 0, array numbered 0 to 9
+ {
+ cout << " \t# " << i + 1 << " of " << NUM_STUDENT << " students:\t";
+ cin >> testScore[i];
+ }
+}
+void LetterG(char letterGrade[], float testScore[], int gradeCounts[])
+{
+
+
+ for (int i = 0; i < NUM_STUDENT; i++)
+ {
+ if (testScore[i] >= 92.0)
+ {
+ letterGrade[i] = 'A';
+ gradeCounts[0] = gradeCounts[0] + 1;
+ }
+
+ else if (testScore[i] >= 84.0 && testScore[i] < 92.0)
+ {
+ letterGrade[i] = 'B';
+ gradeCounts[1] = gradeCounts[1] + 1;
+ }
+
+ else if (testScore[i] >= 75.0 && testScore[i] < 84.0)
+ {
+ letterGrade[i] = 'C';
+ gradeCounts[2] = gradeCounts[2] + 1;
+ }
+
+ else if (testScore[i] >= 65.0 && testScore[i] < 75.0)
+ {
+ letterGrade[i] = 'D';
+ gradeCounts[3] = gradeCounts[3] + 1;
+ }
+
+ else if (testScore[i] < 65.0)
+ {
+ letterGrade[i] = 'F';
+ gradeCounts[4] = gradeCounts[4] + 1;
+ }
+ }
+}
+
+void average(float testScore[])
+{
+ float average = 0.0;
+ float total = 0.0;
+ for (int i = 0; i < NUM_STUDENT; i++)
+ {
+ total = total + testScore[i];
+ }
+
+ average = total / NUM_STUDENT;
+ cout << "\n\n\tClass Average: " << average << "%\n\n";
+ return;
+}
+void displayG(float testScore[], char letterGrade[], int gradeCounts[])
+{
+ for (int i = 0; i < NUM_STUDENT; i++)
+ {
+ cout << " Student # " << i + 1 << ",\tScore: " << testScore[i] << ", Letter Grade: " << letterGrade[i] << "\n";
+ }
+
+ cout << "\n\tThere were " << gradeCounts[0] << " A's\n";
+ cout << "\tThere were " << gradeCounts[1] << " B's\n";
+ cout << "\tThere were " << gradeCounts[2] << " C's\n";
+ cout << "\tThere were " << gradeCounts[3] << " D's\n";
+ cout << "\tThere were " << gradeCounts[4] << " F's\n";
+
+}
+
diff --git a/RUN_CST1162021_Scores_Schroeder.txt b/RUN_CST1162021_Scores_Schroeder.txt
new file mode 100644
index 0000000..ff4030e
--- /dev/null
+++ b/RUN_CST1162021_Scores_Schroeder.txt
@@ -0,0 +1,37 @@
+Enter percent score of student:
+ # 1 of 10 students: 95
+ # 2 of 10 students: 85
+ # 3 of 10 students: 75
+ # 4 of 10 students: 86
+ # 5 of 10 students: 89
+ # 6 of 10 students: 91
+ # 7 of 10 students: 81
+ # 8 of 10 students: 72
+ # 9 of 10 students: 52
+ # 10 of 10 students: 93
+
+
+ Student # 1, Score: 95, Letter Grade: A
+ Student # 2, Score: 85, Letter Grade: B
+ Student # 3, Score: 75, Letter Grade: C
+ Student # 4, Score: 86, Letter Grade: B
+ Student # 5, Score: 89, Letter Grade: B
+ Student # 6, Score: 91, Letter Grade: B
+ Student # 7, Score: 81, Letter Grade: C
+ Student # 8, Score: 72, Letter Grade: D
+ Student # 9, Score: 52, Letter Grade: F
+ Student # 10, Score: 93, Letter Grade: A
+
+ There were 2 A's
+ There were 4 B's
+ There were 2 C's
+ There were 1 D's
+ There were 1 F's
+
+
+ Class Average: 81.9%
+
+
+C:\Users\Lenovo\Source\Repos\cst116-lab5-BensProgramma\x64\Debug\CST116F2021-Lab5.exe (process 14272) exited with code 0.
+To automatically close the console when debugging stops, enable Tools->Options->Debugging->Automatically close the console when debugging stops.
+Press any key to close this window . . .