diff options
Diffstat (limited to 'CST116F2021-Lab5')
| -rw-r--r-- | CST116F2021-Lab5/CST116F2021-Lab5 - Joseph Ten Eyck.cpp | 213 | ||||
| -rw-r--r-- | CST116F2021-Lab5/CST116F2021-Lab5.cpp | 20 | ||||
| -rw-r--r-- | CST116F2021-Lab5/CST116F2021-Lab5.vcxproj | 6 | ||||
| -rw-r--r-- | CST116F2021-Lab5/CST116F2021-Lab5.vcxproj.filters | 10 | ||||
| -rw-r--r-- | CST116F2021-Lab5/Functions.cpp | 172 | ||||
| -rw-r--r-- | CST116F2021-Lab5/Header.h | 53 |
6 files changed, 452 insertions, 22 deletions
diff --git a/CST116F2021-Lab5/CST116F2021-Lab5 - Joseph Ten Eyck.cpp b/CST116F2021-Lab5/CST116F2021-Lab5 - Joseph Ten Eyck.cpp new file mode 100644 index 0000000..e9f2aa3 --- /dev/null +++ b/CST116F2021-Lab5/CST116F2021-Lab5 - Joseph Ten Eyck.cpp @@ -0,0 +1,213 @@ +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// CODE FOR PROBLEM #1 (LEARN BY DOING) ON PAGE 247 IS BELOW +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +//#include <iostream> +//#include <iomanip> +// +//using namespace std; +// +//const int NUM_SCORES = 10; +// +//int main() +//{ +// float currStudent[NUM_SCORES]{ 0.0 }; +// char currStudGradeLTR[NUM_SCORES]{}; +// +// float scoreSum = 0.0; +// float scoreAvg = 0.0; +// +// int freqA = 0; +// int freqB = 0; +// int freqC = 0; +// int freqD = 0; +// int freqF = 0; +// +// cout << "\n\tSTUDENT SCORE GRADER AND SIMPLE CLASS ANALYSIS PROGRAM\n\n"; +// +// for (int i = 0; i < NUM_SCORES; i++) //puts scores into array +// { +// cout << "Enter score #" << i + 1 << " of " << NUM_SCORES << ": "; +// cin >> currStudent[i]; +// } +// +// for (int i = 0; i < NUM_SCORES; i++) //translates scores to grades and puts into another array +// { +// if (currStudent[i] < 65.0) +// { +// currStudGradeLTR[i] = 'F'; +// } +// else if (currStudent[i] >= 65.0 && currStudent[i] < 75.0) +// { +// currStudGradeLTR[i] = 'D'; +// } +// else if (currStudent[i] >= 75.0 && currStudent[i] < 84.0) +// { +// currStudGradeLTR[i] = 'C'; +// } +// else if (currStudent[i] >= 84.0 && currStudent[i] < 92.0) +// { +// currStudGradeLTR[i] = 'B'; +// } +// else if (currStudent[i] >= 92.0) +// { +// currStudGradeLTR[i] = 'A'; +// } +// } +// +// for (int i = 0; i < NUM_SCORES; i++) //finds sum of scores +// { +// scoreSum += currStudent[i]; +// } +// +// scoreAvg = scoreSum / NUM_SCORES; //finds class score average +// +// for (int i = 0; i < NUM_SCORES; i++) //counts frequency of different letter grades +// { +// if (currStudGradeLTR[i] == 'A') +// { +// freqA++; +// } +// if (currStudGradeLTR[i] == 'B') +// { +// freqB++; +// } +// if (currStudGradeLTR[i] == 'C') +// { +// freqC++; +// } +// if (currStudGradeLTR[i] == 'D') +// { +// freqD++; +// } +// if (currStudGradeLTR[i] == 'F') +// { +// freqF++; +// } +// } +// +// cout << "\n\n\t\t Score Grade"; +// +// for (int i = 0; i < NUM_SCORES; i++) //displays list of scores with letter grades +// { +// cout << right << "\n\tScore #" << setw(2) << setfill(char(32)) << i + 1 << ": " +// << setw(7) << setfill(char(32)) << left << currStudent[i] << " " << currStudGradeLTR[i]; +// } +// +// cout << "\n========================================================"; //displays class analysis (average and frequency of letter grades) +// cout << "\n\n\tClass score average: " << scoreAvg; +// cout << "\n\n\n\tFrequency of letter grades:"; +// cout << "\n\n\t\tA: " << freqA; +// cout << "\n\t\tB: " << freqB; +// cout << "\n\t\tC: " << freqC; +// cout << "\n\t\tD: " << freqD; +// cout << "\n\t\tF: " << freqF << "\n\n" << endl; +// +// return 0; +//} + + +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// CODE FOR PROBLEM #1 (LEARN BY DOING) ON PAGE 253 IS BELOW +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +//#include "Header.h" +// +//int main() +//{ +// const int NUM_SCORES = 10; +// +// float currStudent[NUM_SCORES]{ 0.0 }; +// char currStudGradeLTR[NUM_SCORES]{}; +// +// float scoreSum = 0.0; +// float scoreAvg = 0.0; +// +// int freqA = 0; +// int freqB = 0; +// int freqC = 0; +// int freqD = 0; +// int freqF = 0; +// +// cout << "\n\tSTUDENT SCORE GRADER AND SIMPLE CLASS ANALYSIS PROGRAM\n\n"; +// +// //puts scores into array +// GetInput(currStudent, NUM_SCORES); +// +// //translates scores to grades and puts into another array +// ScoreToGrade(currStudent, currStudGradeLTR, NUM_SCORES); +// +// //finds sum and average of scores +// ScoreAvg(currStudent, NUM_SCORES, scoreSum, scoreAvg); +// +// //counts frequency of different letter grades +// Frequency(currStudGradeLTR, NUM_SCORES, freqA, freqB, freqC, freqD, freqF); +// +// +// cout << "\n\n\t\t Score Grade"; +// +// +// //displays list of scores with letter grades and class analysis +// Display(currStudent, currStudGradeLTR, scoreSum, scoreAvg, freqA, freqB, freqC, freqD, freqF, NUM_SCORES); +// +// return 0; +//} + + +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// CODE FOR PROBLEM #2 (LEARN BY DOING) ON PAGE 260 IS BELOW +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +//#include "Header.h" +// +//int main() +//{ +// char firstName[61]{}; +// char lastName[61]{}; +// char fullName[121]{}; +// +// //fullName[0]{ '\32' }; +// +// cout << "\n\t\t========================================="; +// cout << "\n\t\t First/last name combiner using arrays"; +// cout << "\n\t\t========================================="; +// +// //prompts for first and last name and puts them into arrays +// getInput(firstName, lastName); +// +// //combines first and last names into another array +// nameCombine(firstName, lastName, fullName); +// +// //displays full name from array +// display(fullName); +// +// return 0; +//} + + +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// CODE FOR PROBLEM #7 (EXERCISES) ON PAGE 273 IS BELOW +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + +//#include "Header.h" +// +//int main() +//{ +// char string_1[] = "Frank"; +// char string_2[] = "Franklyn"; +// +// int flag = 0; +// +// compareStrings(string_1, string_2, flag); +// +// if (flag != 0) +// { +// cout << "\n\tDifferent" << endl; +// } +// +// else +// { +// cout << "\n\tSame" << endl; +// } +//}
\ No newline at end of file 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..cf85963 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 - Joseph Ten Eyck.cpp" /> + <ClCompile Include="Functions.cpp" /> + </ItemGroup> + <ItemGroup> + <ClInclude Include="Header.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..806288d 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 - Joseph Ten Eyck.cpp"> <Filter>Source Files</Filter> </ClCompile> + <ClCompile Include="Functions.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + </ItemGroup> + <ItemGroup> + <ClInclude Include="Header.h"> + <Filter>Header Files</Filter> + </ClInclude> </ItemGroup> </Project>
\ No newline at end of file diff --git a/CST116F2021-Lab5/Functions.cpp b/CST116F2021-Lab5/Functions.cpp new file mode 100644 index 0000000..622941f --- /dev/null +++ b/CST116F2021-Lab5/Functions.cpp @@ -0,0 +1,172 @@ +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// CODE FOR PROBLEM #1 (LEARN BY DOING) ON PAGE 253 IS BELOW +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +//#include "Header.h" +// +////puts scores into array +//void GetInput(float currStudent[], int NUM_SCORES) +//{ +// for (int i = 0; i < NUM_SCORES; i++) +// { +// cout << "Enter score #" << i + 1 << " of " << NUM_SCORES << ": "; +// cin >> currStudent[i]; +// } +//} +// +////translates scores to grades and puts into another array +//void ScoreToGrade(float currStudent[], char currStudGradeLTR[], int NUM_SCORES) +//{ +// for (int i = 0; i < NUM_SCORES; i++) +// { +// if (currStudent[i] < 65.0) +// { +// currStudGradeLTR[i] = 'F'; +// } +// else if (currStudent[i] >= 65.0 && currStudent[i] < 75.0) +// { +// currStudGradeLTR[i] = 'D'; +// } +// else if (currStudent[i] >= 75.0 && currStudent[i] < 84.0) +// { +// currStudGradeLTR[i] = 'C'; +// } +// else if (currStudent[i] >= 84.0 && currStudent[i] < 92.0) +// { +// currStudGradeLTR[i] = 'B'; +// } +// else if (currStudent[i] >= 92.0) +// { +// currStudGradeLTR[i] = 'A'; +// } +// } +//} +// +////finds sum and average of scores +//void ScoreAvg(float currStudent[], int NUM_SCORES, float& scoreSum, float& scoreAvg) +//{ +// scoreSum = 0.0; +// scoreAvg = 0.0; +// +// for (int i = 0; i < NUM_SCORES; i++) +// { +// scoreSum += currStudent[i]; +// } +// +// scoreAvg = scoreSum / NUM_SCORES; +//} +// +////counts frequency of different letter grades +//void Frequency(char currStudGradeLTR[], int NUM_SCORES, int& freqA, int& freqB, int& freqC, int& freqD, int& freqF) +//{ +// for (int i = 0; i < NUM_SCORES; i++) +// { +// if (currStudGradeLTR[i] == 'A') +// { +// freqA++; +// } +// if (currStudGradeLTR[i] == 'B') +// { +// freqB++; +// } +// if (currStudGradeLTR[i] == 'C') +// { +// freqC++; +// } +// if (currStudGradeLTR[i] == 'D') +// { +// freqD++; +// } +// if (currStudGradeLTR[i] == 'F') +// { +// freqF++; +// } +// } +//} +// +////displays list of scores with letter grades and class analysis +//void Display(float currStudent[], char currStudGradeLTR[], float scoreSum, float scoreAvg, int freqA, int freqB, int freqC, int freqD, int freqF, int NUM_SCORES) +//{ +// for (int i = 0; i < NUM_SCORES; i++) +// { +// cout << right << "\n\tScore #" << setw(2) << setfill(char(32)) << i + 1 << ": " +// << setw(7) << setfill(char(32)) << left << currStudent[i] << " " << currStudGradeLTR[i]; +// } +// +// cout << "\n========================================================"; +// cout << "\n\n\tClass score average: " << scoreAvg; +// cout << "\n\n\n\tFrequency of letter grades:"; +// cout << "\n\n\t\tA: " << freqA; +// cout << "\n\t\tB: " << freqB; +// cout << "\n\t\tC: " << freqC; +// cout << "\n\t\tD: " << freqD; +// cout << "\n\t\tF: " << freqF << "\n\n" << endl; +//} + + +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// CODE FOR PROBLEM #2 (LEARN BY DOING) ON PAGE 260 IS BELOW +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +//#include "Header.h" +// +////prompts for first and last name and puts them into arrays +//void getInput(char firstName[], char lastName[]) +//{ +// cout << "\n\n\tEnter first name: "; +// cin.getline(firstName, 61); +// +// cout << "\n\tEnter last name: "; +// cin.getline(lastName, 61); +//} +// +////combines first and last names into another array, adds a comma and space between them +//void nameCombine(char firstName[], char lastName[], char fullName[]) +//{ +// int index = 0; +// +// for (int i = 0; lastName[i] != '\0'; i++) //puts lastName into fullName +// { +// fullName[i] = lastName[i]; +// } +// +// for (int i = 0; fullName[i] != '\0'; i++) //counts fullName current length +// { +// index++; +// } +// +// fullName[index] = ','; //adds comma and space +// fullName[index + 1] = ' '; +// +// for (int i = 0; firstName[i] != '\0'; i++) +// { +// fullName[i + index + 2] = firstName[i]; +// } +//} +// +////displays full name from array +//void display(char firstName[]) +//{ +// cout << "\n\n===================================================="; +// cout << "\n\n\tYour full name is: " << firstName << "\n" << endl; +//} + + +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// CODE FOR PROBLEM #7 (EXERCISES) ON PAGE 273 IS BELOW +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + +//#include "Header.h" +// +////compares the first 6 characters of the two strings +//void compareStrings(char string_1[], char string_2[], int& flag) +//{ +// for (int i = 0; i <= 5; i++) +// { +// if (string_1[i] != string_2[i]) +// { +// flag++; +// } +// } +//}
\ No newline at end of file diff --git a/CST116F2021-Lab5/Header.h b/CST116F2021-Lab5/Header.h new file mode 100644 index 0000000..7009bf8 --- /dev/null +++ b/CST116F2021-Lab5/Header.h @@ -0,0 +1,53 @@ +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// CODE FOR PROBLEM #1 (LEARN BY DOING) ON PAGE 253 IS BELOW +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +//#include <iostream> +//#include <iomanip> +// +//using namespace std; +// +// +//void Display(float[], char[], float, float, int, int, int, int, int, int); //displays list of scores with letter grades and class analysis +// +//void GetInput(float[], int); //puts scores into array +// +//void ScoreToGrade(float[], char[], int); //translates scores to grades and puts into another array +// +//void ScoreAvg(float[], int, float&, float&); //finds sum and average of scores +// +//void Frequency(char[], int, int&, int&, int&, int&, int&); //counts frequency of different letter grades + + + +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// CODE FOR PROBLEM #2 (LEARN BY DOING) ON PAGE 260 IS BELOW +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +//#include <iostream> +//#include <iomanip> +// +//using namespace std; +// +////prompts for first and last name and puts them into arrays +//void getInput(char[], char[]); +// +////combines first and last names into another array +//void nameCombine(char[], char[], char[]); +// +////displays full name from array +//void display(char[]); + + +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// CODE FOR PROBLEM #7 (EXERCISES) ON PAGE 273 IS BELOW +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + +//#include <iostream> +//#include<iomanip> +// +//using namespace std; +// +////compares the first 6 characters of the two strings +//void compareStrings(char[], char[], int&); |