diff options
| -rw-r--r-- | CST116F2021-Lab5/CST116-lab5-Functions.cpp | 130 | ||||
| -rw-r--r-- | CST116F2021-Lab5/CST116-lab5.h | 35 | ||||
| -rw-r--r-- | CST116F2021-Lab5/CST116F2021-Lab5.cpp | 119 | ||||
| -rw-r--r-- | CST116F2021-Lab5/CST116F2021-Lab5.vcxproj | 4 | ||||
| -rw-r--r-- | CST116F2021-Lab5/CST116F2021-Lab5.vcxproj.filters | 8 |
5 files changed, 284 insertions, 12 deletions
diff --git a/CST116F2021-Lab5/CST116-lab5-Functions.cpp b/CST116F2021-Lab5/CST116-lab5-Functions.cpp new file mode 100644 index 0000000..6502081 --- /dev/null +++ b/CST116F2021-Lab5/CST116-lab5-Functions.cpp @@ -0,0 +1,130 @@ +// File: CST116-Lab_5-FUnctions.cpp +// Summary: A compilation of all function files in lab 5 +// Author: Logan Billingsley +// Date: 11/2/2021 + +#include "CST116-lab5.h" + + // 9b -- 10.6 Learn by Doing Exercises +/* +void GetScores(float scores[]) +{ + for (int i = 0; i < SIZE; i++) // Get scores + { + cout << "Please enter score " << i + 1 << ": "; + cin >> scores[i]; + cout << endl; + } + return; +} +void DisplayScores(float scores[], int& A, int& B, int& C, int& D, int& F) +{ + for (int i = 0; i < SIZE; i++) // Display scores and letter grade. + { + cout << "Score " << i + 1 << ": " << scores[i] << ' '; + if (scores[i] >= 92) + { + cout << "A\n\n"; + A++; + } + else if (scores[i] >= 84) + { + cout << "B\n\n"; + B++; + } + else if (scores[i] >= 75) + { + cout << "C\n\n"; + C++; + } + else if (scores[i] >= 65) + { + cout << "D\n\n"; + D++; + } + else + { + cout << "F\n\n"; + F++; + } + } + return; +} +void DisplayTotals(int A, int B, int C, int D, int F) +{ + cout << "There were a total of: \n" + << A << " A's\n" + << B << " B's\n" + << C << " C's\n" + << D << " D's\n" + << F << " F's\n\n"; + return; +} +*/ + + // 10a -- 10.7 Learn by Doing Exercies 2 +/* +void GetNames(char first[], char last[]) +{ + cout << "Input your first name: "; + cin >> first; + cout << endl; + cout << "Input your last name: "; + cin >> last; + cout << endl << endl; + return; +} +void FullName(char first[], char last[], char full[]) +{ + int i = 0; + for (int j = 0; last[j] != '\0'; j++) + { + full[i] = last[j]; + i++; + } + full[i] = ','; + i++; + full[i] = ' '; + i++; + for (int j = 0; first[j] != '\0'; j++) + { + full[i] = first[j]; + i++; + } + full[i] = '\0'; + return; +} +void PrintName(char full[]) +{ + cout << "Full Name: " << full << endl; + return; +} +*/ + + // 10b -- 10.8 Exercies 7 +/* +void GetString1(char string1[]) +{ + cout << "Please input name 1: "; + cin.getline(string1, SIZE); + cin.clear(); + cin.ignore(cin.rdbuf()->in_avail()); +} +void GetString2(char string2[]) +{ + cout << "Please input name 2: "; + cin.getline(string2, SIZE); +} +void CompareStrings(char string1[], char string2[]) +{ + int result; + + result = strncmp(string1, string2, 6); + + if (result == 0) + cout << "Same\n\n"; + else + cout << "Different\n\n"; + +} +*/
\ No newline at end of file diff --git a/CST116F2021-Lab5/CST116-lab5.h b/CST116F2021-Lab5/CST116-lab5.h new file mode 100644 index 0000000..d3e82e7 --- /dev/null +++ b/CST116F2021-Lab5/CST116-lab5.h @@ -0,0 +1,35 @@ +// File: CST116-Lab_5.h +// Summary: A compilation of header files for Lab 5 +// Author: Logan Billingsley +// Date: 11/2/2021 + +#include <iostream> +#include <cstring> +using namespace std; + + // 9b -- 10.6 Learn by Doing Exercises +/* +const int SIZE = 10; + +void GetScores(float[]); +void DisplayScores(float scores[], int&, int&, int&, int&, int&); +void DisplayTotals(int, int, int, int, int); +*/ + + // 10a -- 10.7 Learn by Doing Exercies 2 +/* +const int SIZE = 20 + 1; + +void GetNames(char[], char[]); +void FullName(char[], char[], char[]); +void PrintName(char[]); +*/ + + // 10b -- 10.8 Exercies 7 +/* +const int SIZE = 20 + 1; + +void GetString1(char[]); +void GetString2(char[]); +void CompareStrings(char[], char[]); +*/
\ No newline at end of file diff --git a/CST116F2021-Lab5/CST116F2021-Lab5.cpp b/CST116F2021-Lab5/CST116F2021-Lab5.cpp index e7591f7..fe1596f 100644 --- a/CST116F2021-Lab5/CST116F2021-Lab5.cpp +++ b/CST116F2021-Lab5/CST116F2021-Lab5.cpp @@ -1,20 +1,115 @@ -// CST116F2021-Lab5.cpp : This file contains the 'main' function. Program execution begins and ends there. -// +// File: CST116-Lab_5-Billingsley.cpp +// Summary: A compilation of all coding exercises in lab 5 +// Author: Logan Billingsley +// Date: 11/2/2021 +#include "CST116-lab5.h" + + // 9a -- 10.5 Learn by Doing Exercises +/* #include <iostream> +using namespace std; + +const int SIZE = 10; + +int main() +{ + float scores[SIZE]; + int A = 0, + B = 0, + C = 0, + D = 0, + F = 0; + + for (int i = 0; i < SIZE; i++) // Get scores + { + cout << "Please enter score " << i + 1 << ": "; + cin >> scores[i]; + cout << endl; + } + for (int i = 0; i < SIZE; i++) // Display scores and letter grade. + { + cout << "Score " << i + 1 << ": " << scores[i] << ' '; + if (scores[i] >= 92) + { + cout << "A\n\n"; + A++; + } + else if (scores[i] >= 84) + { + cout << "B\n\n"; + B++; + } + else if (scores[i] >= 75) + { + cout << "C\n\n"; + C++; + } + else if (scores[i] >= 65) + { + cout << "D\n\n"; + D++; + } + else + { + cout << "F\n\n"; + F++; + } + } + cout << "There were a total of: \n" + << A << " A's\n" + << B << " B's\n" + << C << " C's\n" + << D << " D's\n" + << F << " F's\n\n"; + return 0; +} +*/ + + // 9b -- 10.6 Learn by Doing Exercises +/* +int main() +{ + float scores[SIZE]; + int A = 0, + B = 0, + C = 0, + D = 0, + F = 0; + + GetScores(scores); + DisplayScores(scores, A, B, C, D, F); + DisplayTotals(A, B, C, D, F); + return 0; +} +*/ + + // 10a -- 10.7 Learn by Doing Exercies 2 +/* int main() { - std::cout << "Hello World!\n"; + char first[SIZE], + last[SIZE], + full[SIZE*3]; + + GetNames(first, last); + FullName(first, last, full); + PrintName(full); + + return 0; } +*/ -// Run program: Ctrl + F5 or Debug > Start Without Debugging menu -// Debug program: F5 or Debug > Start Debugging menu + // 10b -- 10.8 Exercies 7 +/* +int main() +{ + char string1[SIZE], + string2[SIZE]; -// 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 + GetString1(string1); + GetString2(string2); + CompareStrings(string1, string2); +} +*/
\ No newline at end of file diff --git a/CST116F2021-Lab5/CST116F2021-Lab5.vcxproj b/CST116F2021-Lab5/CST116F2021-Lab5.vcxproj index 14ee2b7..3717b86 100644 --- a/CST116F2021-Lab5/CST116F2021-Lab5.vcxproj +++ b/CST116F2021-Lab5/CST116F2021-Lab5.vcxproj @@ -139,8 +139,12 @@ </Link> </ItemDefinitionGroup> <ItemGroup> + <ClCompile Include="CST116-lab5-Functions.cpp" /> <ClCompile Include="CST116F2021-Lab5.cpp" /> </ItemGroup> + <ItemGroup> + <ClInclude Include="CST116-lab5.h" /> + </ItemGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <ImportGroup Label="ExtensionTargets"> </ImportGroup> diff --git a/CST116F2021-Lab5/CST116F2021-Lab5.vcxproj.filters b/CST116F2021-Lab5/CST116F2021-Lab5.vcxproj.filters index c9f2fd4..844607a 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="CST116-lab5-Functions.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + </ItemGroup> + <ItemGroup> + <ClInclude Include="CST116-lab5.h"> + <Filter>Header Files</Filter> + </ClInclude> </ItemGroup> </Project>
\ No newline at end of file |