diff options
| author | BensProgramma <[email protected]> | 2021-11-02 15:57:42 -0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-11-02 15:57:42 -0700 |
| commit | 3ccdeefb1d4d7fce2678ec2fde719f6da7c479ec (patch) | |
| tree | 74314525a0692057314cba610cf5d2f4c362c133 | |
| parent | Update RUN_CST1162021_Scores_Schroeder.txt (diff) | |
| download | cst116-lab5-bensprogramma-3ccdeefb1d4d7fce2678ec2fde719f6da7c479ec.tar.xz cst116-lab5-bensprogramma-3ccdeefb1d4d7fce2678ec2fde719f6da7c479ec.zip | |
Update RUN_CST1162021_Scores_Schroeder.txt
| -rw-r--r-- | RUN_CST1162021_Scores_Schroeder.txt | 193 |
1 files changed, 106 insertions, 87 deletions
diff --git a/RUN_CST1162021_Scores_Schroeder.txt b/RUN_CST1162021_Scores_Schroeder.txt index b831beb..3349a9e 100644 --- a/RUN_CST1162021_Scores_Schroeder.txt +++ b/RUN_CST1162021_Scores_Schroeder.txt @@ -1,7 +1,7 @@ -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -Lab5 Exercises 10.5, 10.6, 10.7, and 10.8#7 Benjamin Schroeder +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +Lab5 Exercises 10.5, 10.6, 10.7, and 10.8#7 Benjamin Schroeder -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Exercise 10.6 and 10.7 //HEADER FILE "Scores.h" ///////////////////////////////////////////////////////////////////// #pragma once @@ -17,9 +17,32 @@ void LetterG(char[], float[], int[]); void average(float[]); void displayG(float[], char[], int[]); +void TenSix(); // 10.6 program function +void TenSeven(); //10.7 program function +void TenEight_Seven(); // 10.8_7 Program function + +// + + + + //FUNCTIONS FILE "ScoresFunctions.cpp" /////////////////////////////////////////////////////////// -#include "Scores.h" + + 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'; + +#include "Lab5Exercises.h" + void ReadScores(float testScore[]) { @@ -31,21 +54,10 @@ void ReadScores(float testScore[]) 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; +gradeCounts[1] = gradeCounts[1] + 1; } else if (testScore[i] >= 75.0 && testScore[i] < 84.0) @@ -81,7 +93,6 @@ void average(float testScore[]) 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++) @@ -94,27 +105,87 @@ void displayG(float testScore[], char letterGrade[], int gradeCounts[]) cout << "\tThere were " << gradeCounts[2] << " C's\n"; cout << "\tThere were " << gradeCounts[3] << " D's\n"; cout << "\tThere were " << gradeCounts[4] << " F's\n"; + } -///// main() FILE ///////////////////////////////////////////////////////////////////////////////// - -#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); -} +void TenSix() + // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // p247 10.5 and 10.6 Learn by doing exercises - /////// + { + 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); + + } + + void TenSeven() + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // p260 10.7 Learn by doing exercise + { + char First[41]{}; + char Last[41]{}; + char Full[81]{}; + + cout << "Enter your first name: "; + cin.ignore(cin.rdbuf()->in_avail()); + cin.getline(First, 41); + cin.clear(); + cin.ignore(cin.rdbuf()->in_avail()); + + + cout << "Enter your last name: "; + cin.ignore(cin.rdbuf()->in_avail()); + cin.getline(Last, 41); + cin.clear(); + cin.ignore(cin.rdbuf()->in_avail()); + + for (int i = 0; i < strlen(Last); i++) + Full[i] = Last[i]; + Full[strlen(Last)] = ','; + Full[strlen(Last) + 1] = ' '; + for (int j = 0; j < strlen(First); j++) + Full[strlen(Last) + 2 + j] = First[j]; + + cout << "Contents of the 'Full Name Array': " << Full<< "\n\n"; + } + + + void TenEight_Seven() + { + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // Exercise 10.8 #7 p273 + + char string_1[] = "Frank"; + char string_2[] = "Franklyn"; + + + int differnt = 0; + + for (int i = 0; i < 6; i++) + if (string_1[i] != string_2[i]) + differnt = differnt + 1; + if (differnt > 0) + cout << "Different\n"; + else + cout << "Same\n"; + + } + + + +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + /////// Run from Exercises 10.5-10.6 Learn By Doing Enter percent score of student: @@ -157,39 +228,8 @@ Press any key to close this window . . . ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// Exercise 10.7 Learn By Doing - -int main() -{ - char First[41]{}; - char Last[41]{}; - char Full[81]{}; - - cout << "Enter your first name: "; - cin.ignore(cin.rdbuf()->in_avail()); - cin.getline(First, 41); - cin.clear(); - cin.ignore(cin.rdbuf()->in_avail()); - - - cout << "Enter your last name: "; - cin.ignore(cin.rdbuf()->in_avail()); - cin.getline(Last, 41); - cin.clear(); - cin.ignore(cin.rdbuf()->in_avail()); - - for (int i = 0; i < strlen(Last); i++) - Full[i] = Last[i]; - Full[strlen(Last)] = ','; - Full[strlen(Last)+1] = ' '; - for (int j = 0; j <strlen(First); j++) - Full[strlen(Last)+2+j] = First[j]; - - cout <<"Contents of the 'Full Name Array': "<< Full; -} - ////// + ////// RUN from Exercise 10.7 Learn By Doing Enter your first name: Benjamin @@ -203,34 +243,13 @@ To automatically close the console when debugging stops, enable Tools->Options-> Press any key to close this window . . . ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//Exercise 10.8 #7 -#include<iostream> -using namespace std; - -char string_1[] = "Frank"; -char string_2[] = "Franklyn"; - -int main() -{ - - int compare = strncmp(string_1, string_2, 6); - cout << "Comparing the first 6 chars of strings: '" << string_1 << "' and '" << string_2 << "'"; - if (compare == 0) - cout << "\nSame\n"; - else if (compare < 0) - cout << "\nDifferent\n"; -} - - ////// + ////// Run from Exercise 10.8 #7 - -Comparing the first 6 chars of strings: 'Frank' and 'Franklyn' Different C:\Users\Lenovo\Source\Repos\cst116-lab5-BensProgramma\x64\Debug\CST116F2021-Lab5.exe (process 21936) 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 . . . -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |