diff options
Diffstat (limited to 'CST116F2021-Lab6/CST116F2021-Lab6.cpp')
| -rw-r--r-- | CST116F2021-Lab6/CST116F2021-Lab6.cpp | 105 |
1 files changed, 95 insertions, 10 deletions
diff --git a/CST116F2021-Lab6/CST116F2021-Lab6.cpp b/CST116F2021-Lab6/CST116F2021-Lab6.cpp index 466d90f..843a5cf 100644 --- a/CST116F2021-Lab6/CST116F2021-Lab6.cpp +++ b/CST116F2021-Lab6/CST116F2021-Lab6.cpp @@ -2,19 +2,104 @@ // #include <iostream> +#include <cstring> + +using namespace std; +#define ARRAY_SIZE 10 +void inputData(int[ARRAY_SIZE], string[ARRAY_SIZE][2]); +void fundCalc(int[ARRAY_SIZE], int[ARRAY_SIZE]); +void tableDisp(int[ARRAY_SIZE], int[ARRAY_SIZE], string[ARRAY_SIZE][2]); int main() { - std::cout << "Hello World!\n"; + int student_number[ARRAY_SIZE]{}, fund_value[ARRAY_SIZE]{}; + string club_pres_name[ARRAY_SIZE][2]{}; + + inputData(student_number, club_pres_name); + fundCalc(student_number, fund_value); + } -// 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 +void inputData(int inputStuNum[ARRAY_SIZE], string inputClubPres[ARRAY_SIZE][2]) +{ + int i = 0; + + while (i < ARRAY_SIZE) + { + cout << "Please enter the club name: "; + cin >> inputClubPres[i][0]; + cout << "Please enter the club president: "; + cin >> inputClubPres[i][1]; + cout << "Please enter the number of students in " << inputClubPres[i][0] << ': '; + cin >> inputStuNum[i]; + cout << endl; + i++; + } + cout << endl; +} + +void fundCalc(int calcNumStu[ARRAY_SIZE], int calcFund[ARRAY_SIZE]) +{ + int i = 0; + + while (i < ARRAY_SIZE) + { + calcFund[i] = calcNumStu[i] * 75; + i++; + } +} + +void tableDisp(int dispNumStu[ARRAY_SIZE], int dispFund[ARRAY_SIZE], string dispPresClub[ARRAY_SIZE][2]) +{ + int i = 0; + cout << "Student Club\tPresident\tNumber of Students\tClub Fund" << endl; + while (i < ARRAY_SIZE) + { + cout << dispPresClub[i][0] << '\t' << dispPresClub[i][1] << '\t' << dispNumStu[i] << '\t' << dispFund[i]; + cout << endl; + i++; + } + +} + +////temp +//#define ARRAY_SIZE 5 +//void readData(int[ARRAY_SIZE][2], string[ARRAY_SIZE][2]); +// +// +////temp +//int main() +//{ +// int id_age[ARRAY_SIZE][2]{}; +// string name_gender[ARRAY_SIZE][2]{}; +// +// readData(id_age, name_gender); +// +// return 0; +//} +// +//void readData(int intData[ARRAY_SIZE][2], string stringData[ARRAY_SIZE][2]) +//{ +// int again = 1, i = 0; +// +// //while again holds a value other than 0, program will read true +// while (again && i < ARRAY_SIZE) +// { +// cout << "Enter the ID (0 to exit): "; +// cin >> again; +// if (again) +// { +// intData[i][0] = again; +// cout << "Enter the name: "; +// cin >> stringData[i][0]; +// cout << "Enter the age: "; +// cin >> intData[i][1]; +// cout << "Enter the gender: "; +// cin >> stringData[i][1]; +// cout << endl; +// i++; +// } +// } +// cout << endl; +//}
\ No newline at end of file |