aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWiserJ <[email protected]>2021-10-27 16:40:09 -0700
committerWiserJ <[email protected]>2021-10-27 16:40:09 -0700
commit4a00483d3e5af81ab55d4f077499f73ae9e014e0 (patch)
tree3b277621ab77a3cf8c220e659aee760f705569f2
parent10.6 final (diff)
downloadcst116-lab5-jeffwoit-4a00483d3e5af81ab55d4f077499f73ae9e014e0.tar.xz
cst116-lab5-jeffwoit-4a00483d3e5af81ab55d4f077499f73ae9e014e0.zip
3 file solution
-rw-r--r--CST116F2021-Lab5/CST116F2021-Lab5.cpp161
-rw-r--r--CST116F2021-Lab5/CST116F2021-Lab5.vcxproj4
-rw-r--r--CST116F2021-Lab5/CST116F2021-Lab5.vcxproj.filters8
-rw-r--r--CST116F2021-Lab5/Header1.h12
-rw-r--r--CST116F2021-Lab5/Source1.cpp70
-rw-r--r--Header1.h13
-rw-r--r--Source1.cpp70
7 files changed, 258 insertions, 80 deletions
diff --git a/CST116F2021-Lab5/CST116F2021-Lab5.cpp b/CST116F2021-Lab5/CST116F2021-Lab5.cpp
index 2b9258b..d305c1e 100644
--- a/CST116F2021-Lab5/CST116F2021-Lab5.cpp
+++ b/CST116F2021-Lab5/CST116F2021-Lab5.cpp
@@ -1,19 +1,20 @@
// CST116F2021-Lab5.cpp : This file contains the 'main' function. Program execution begins and ends there.
//
-#include <iostream>
-//#include "Header1.h"
-using namespace std;
-
-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;
-const int NUM_GRADE = 5;
+#include "Header1.h"
+//#include <iostream>
+//
+//using namespace std;
+//
+//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;
+//const int NUM_GRADE = 5;
int main()
{
@@ -31,74 +32,74 @@ int main()
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 >> score_input[i];
- }
-}
-
-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 (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_output[i] = 'F';
-
- cout << "\nTest #" << i + 1 << " scored " << score_input[i] << " and received grade " << grade_output[i];
- }
-}
-
-float calcAvg(float score_input[], float avg)
-{
- //Calc class average
- for (int i = 0; i < NUM_SCORES; i++)
- {
- avg += score_input[i];
- }
-
- avg /= NUM_SCORES;
-
- cout << "\n\nThe class average for " << NUM_SCORES << " scores is " << avg << endl;
-
- return avg;
-}
-
-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_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
- nGrade[4] += 1;
- }
-
- 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];
-}
+//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 >> score_input[i];
+// }
+//}
+//
+//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 (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_output[i] = 'F';
+//
+// cout << "\nTest #" << i + 1 << " scored " << score_input[i] << " and received grade " << grade_output[i];
+// }
+//}
+//
+//float calcAvg(float score_input[], float avg)
+//{
+// //Calc class average
+// for (int i = 0; i < NUM_SCORES; i++)
+// {
+// avg += score_input[i];
+// }
+//
+// avg /= NUM_SCORES;
+//
+// cout << "\n\nThe class average for " << NUM_SCORES << " scores is " << avg << endl;
+//
+// return avg;
+//}
+//
+//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_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
+// nGrade[4] += 1;
+// }
+//
+// 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
//const int NUM_SCORES = 10;
diff --git a/CST116F2021-Lab5/CST116F2021-Lab5.vcxproj b/CST116F2021-Lab5/CST116F2021-Lab5.vcxproj
index 14ee2b7..2bceceb 100644
--- a/CST116F2021-Lab5/CST116F2021-Lab5.vcxproj
+++ b/CST116F2021-Lab5/CST116F2021-Lab5.vcxproj
@@ -140,6 +140,10 @@
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="CST116F2021-Lab5.cpp" />
+ <ClCompile Include="Source1.cpp" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="Header1.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..f7a8d4b 100644
--- a/CST116F2021-Lab5/CST116F2021-Lab5.vcxproj.filters
+++ b/CST116F2021-Lab5/CST116F2021-Lab5.vcxproj.filters
@@ -18,5 +18,13 @@
<ClCompile Include="CST116F2021-Lab5.cpp">
<Filter>Source Files</Filter>
</ClCompile>
+ <ClCompile Include="Source1.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="Header1.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
</ItemGroup>
</Project> \ No newline at end of file
diff --git a/CST116F2021-Lab5/Header1.h b/CST116F2021-Lab5/Header1.h
index 6f70f09..693d4af 100644
--- a/CST116F2021-Lab5/Header1.h
+++ b/CST116F2021-Lab5/Header1.h
@@ -1 +1,13 @@
+#include <iostream>
+
+using namespace std;
+
+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;
+const int NUM_GRADE = 5;
#pragma once
diff --git a/CST116F2021-Lab5/Source1.cpp b/CST116F2021-Lab5/Source1.cpp
index e69de29..9e7b450 100644
--- a/CST116F2021-Lab5/Source1.cpp
+++ b/CST116F2021-Lab5/Source1.cpp
@@ -0,0 +1,70 @@
+#include "Header1.h"
+
+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 >> score_input[i];
+ }
+}
+
+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 (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_output[i] = 'F';
+
+ cout << "\nTest #" << i + 1 << " scored " << score_input[i] << " and received grade " << grade_output[i];
+ }
+}
+
+float calcAvg(float score_input[], float avg)
+{
+ //Calc class average
+ for (int i = 0; i < NUM_SCORES; i++)
+ {
+ avg += score_input[i];
+ }
+
+ avg /= NUM_SCORES;
+
+ cout << "\n\nThe class average for " << NUM_SCORES << " scores is " << avg << endl;
+
+ return avg;
+}
+
+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_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
+ nGrade[4] += 1;
+ }
+
+ 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];
+} \ No newline at end of file
diff --git a/Header1.h b/Header1.h
new file mode 100644
index 0000000..693d4af
--- /dev/null
+++ b/Header1.h
@@ -0,0 +1,13 @@
+#include <iostream>
+
+using namespace std;
+
+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;
+const int NUM_GRADE = 5;
+#pragma once
diff --git a/Source1.cpp b/Source1.cpp
new file mode 100644
index 0000000..9e7b450
--- /dev/null
+++ b/Source1.cpp
@@ -0,0 +1,70 @@
+#include "Header1.h"
+
+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 >> score_input[i];
+ }
+}
+
+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 (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_output[i] = 'F';
+
+ cout << "\nTest #" << i + 1 << " scored " << score_input[i] << " and received grade " << grade_output[i];
+ }
+}
+
+float calcAvg(float score_input[], float avg)
+{
+ //Calc class average
+ for (int i = 0; i < NUM_SCORES; i++)
+ {
+ avg += score_input[i];
+ }
+
+ avg /= NUM_SCORES;
+
+ cout << "\n\nThe class average for " << NUM_SCORES << " scores is " << avg << endl;
+
+ return avg;
+}
+
+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_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
+ nGrade[4] += 1;
+ }
+
+ 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];
+} \ No newline at end of file