From 5bcf8d36d9004dde2792a9e35159df253c90c2bb Mon Sep 17 00:00:00 2001 From: Benjamin Schroeder Date: Wed, 3 Nov 2021 16:32:52 -0700 Subject: Lab6 Exercises --- CST116F2021-Lab6/CST116F2021-Lab6.cpp | 20 ------ CST116F2021-Lab6/CST116F2021-Lab6.vcxproj | 6 +- CST116F2021-Lab6/CST116F2021-Lab6.vcxproj.filters | 10 ++- CST116F2021-Lab6/CST116F2021-Lab6_Schroeder.cpp | 21 ++++++ CST116F2021-Lab6/Lab6ExerciseFunctions.cpp | 85 +++++++++++++++++++++++ CST116F2021-Lab6/Lab6_Header.h | 11 +++ 6 files changed, 131 insertions(+), 22 deletions(-) delete mode 100644 CST116F2021-Lab6/CST116F2021-Lab6.cpp create mode 100644 CST116F2021-Lab6/CST116F2021-Lab6_Schroeder.cpp create mode 100644 CST116F2021-Lab6/Lab6ExerciseFunctions.cpp create mode 100644 CST116F2021-Lab6/Lab6_Header.h diff --git a/CST116F2021-Lab6/CST116F2021-Lab6.cpp b/CST116F2021-Lab6/CST116F2021-Lab6.cpp deleted file mode 100644 index 466d90f..0000000 --- a/CST116F2021-Lab6/CST116F2021-Lab6.cpp +++ /dev/null @@ -1,20 +0,0 @@ -// CST116F2021-Lab6.cpp : This file contains the 'main' function. Program execution begins and ends there. -// - -#include - -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-Lab6/CST116F2021-Lab6.vcxproj b/CST116F2021-Lab6/CST116F2021-Lab6.vcxproj index 756680b..3dcb4a4 100644 --- a/CST116F2021-Lab6/CST116F2021-Lab6.vcxproj +++ b/CST116F2021-Lab6/CST116F2021-Lab6.vcxproj @@ -139,7 +139,11 @@ - + + + + + diff --git a/CST116F2021-Lab6/CST116F2021-Lab6.vcxproj.filters b/CST116F2021-Lab6/CST116F2021-Lab6.vcxproj.filters index afbfcf4..3aef1e0 100644 --- a/CST116F2021-Lab6/CST116F2021-Lab6.vcxproj.filters +++ b/CST116F2021-Lab6/CST116F2021-Lab6.vcxproj.filters @@ -15,8 +15,16 @@ - + Source Files + + Source Files + + + + + Header Files + \ No newline at end of file diff --git a/CST116F2021-Lab6/CST116F2021-Lab6_Schroeder.cpp b/CST116F2021-Lab6/CST116F2021-Lab6_Schroeder.cpp new file mode 100644 index 0000000..71a80ec --- /dev/null +++ b/CST116F2021-Lab6/CST116F2021-Lab6_Schroeder.cpp @@ -0,0 +1,21 @@ +// CST116F2021-Lab6.cpp : This file contains the 'main' function. Program execution begins and ends there. +// +// Lab6Exercises_Schroeder.cpp : This file contains the 'main' function. Program execution begins and ends there. +// + +#include "Lab6_Header.h" + + +int main() +{ + int Mem_Dues[ARRAY_SIZE][2]{}; + string Club_Pres[ARRAY_SIZE][2]{}; + readData(Mem_Dues, Club_Pres); + printData(Mem_Dues, Club_Pres); + +} + + + + +//10.10 Learn by Doing diff --git a/CST116F2021-Lab6/Lab6ExerciseFunctions.cpp b/CST116F2021-Lab6/Lab6ExerciseFunctions.cpp new file mode 100644 index 0000000..dd96a34 --- /dev/null +++ b/CST116F2021-Lab6/Lab6ExerciseFunctions.cpp @@ -0,0 +1,85 @@ +#include "Lab6_Header.h" +/* /// This is an Example that Martha Showed us in class +#define ARRAY_SIZE 5 +void readData(int[ARRAY_SIZE][2], string[ARRAY_SIZE][2]); + + +int main() +{ + int id_age[ARRAY_SIZE][2]{}; + string name_gender[ARRAY_SIZE][2]{}; + readData(id_age, name_gender); +} + + +void readData(int intData[ARRAY_SIZE][2], string stringData[ARRAY_SIZE][2]) +{ + int again = 1, i = 0; + + while (again && i < ARRAY_SIZE) + { + cout << "Enter the ID (0 to EXIT):"; + cin >> again; + if (again) + { + intData[i][0] = again; + cout << "Enter the name: "; + getline(cin >> ws, stringData[i][0]); + cout << "Enter the age: "; + cin >> intData[i][1]; + cout << "Enter the gender: "; + getline(cin >> ws,stringData[i][1]; + cout << endl; + i++; + } + } + cout << endl; +} + +*/ + + + + +//10.10 Learn by Doing p282-283 +void readData(int intData[ARRAY_SIZE][2], string stringData[ARRAY_SIZE][2]) +{ + int again = 0, i = 0; + cout << "Another Club's Data? (1 for YES, 0 to exit) "; + cin >> again; + while (again && i < ARRAY_SIZE) + { + cout << "Enter the club name: "; + getline(cin >> ws, stringData[i][0]); + cout << "Enter number of members:"; + cin >> intData[i][0]; + cout << "Enter the Club president's name: "; + getline(cin >> ws, stringData[i][1]); + intData[i][1] = intData[i][0] * 75; + cout << endl; + cout << "Another Club's Data? (1 for YES, 0 to exit)"; + cin >> again; + i++; + } + + + cout << endl; +} + +void printData(int intData[ARRAY_SIZE][2], string stringData[ARRAY_SIZE][2]) +{ + cout << setw(20) << "\t\t\tClub" << setw(10) << "\t\tmembers" << setw(20) << "\tPresident" << setw(10) << "\t\tDues $$\n\n"; + for (int i = 0; i < ARRAY_SIZE; i++) + { + cout << "Record " << i + 1 << " is: \t"; + for (int j = 0; j < 2; j++) + { + cout << setw(30) << stringData[i][j] << setw(10) << intData[i][j]; + + } + cout << endl; + } +} + + + diff --git a/CST116F2021-Lab6/Lab6_Header.h b/CST116F2021-Lab6/Lab6_Header.h new file mode 100644 index 0000000..4c86919 --- /dev/null +++ b/CST116F2021-Lab6/Lab6_Header.h @@ -0,0 +1,11 @@ +#pragma once +#include +#include +#include +using namespace std; + +#define ARRAY_SIZE 10 +void readData(int[ARRAY_SIZE][2], string[ARRAY_SIZE][2]); +void printData(int[ARRAY_SIZE][2], string[ARRAY_SIZE][2]); + + -- cgit v1.2.3