diff options
| -rw-r--r-- | CST116F2021-Lab6/CST116F2021-Lab6.cpp | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/CST116F2021-Lab6/CST116F2021-Lab6.cpp b/CST116F2021-Lab6/CST116F2021-Lab6.cpp index 843a5cf..6eba091 100644 --- a/CST116F2021-Lab6/CST116F2021-Lab6.cpp +++ b/CST116F2021-Lab6/CST116F2021-Lab6.cpp @@ -2,36 +2,39 @@ // #include <iostream> +#include <string> +#include <iomanip> #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]); +void inputData(int[], string[][2]); +void fundCalc(int[], int[]); +void tableDisp(int[], int[], string[][2]); int main() { 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); } -void inputData(int inputStuNum[ARRAY_SIZE], string inputClubPres[ARRAY_SIZE][2]) +void inputData(int inputStuNum[], string inputClubPres[][2]) { int i = 0; while (i < ARRAY_SIZE) { cout << "Please enter the club name: "; - cin >> inputClubPres[i][0]; + getline(cin >> ws,inputClubPres[i][0]); cout << "Please enter the club president: "; - cin >> inputClubPres[i][1]; - cout << "Please enter the number of students in " << inputClubPres[i][0] << ': '; + getline(cin >> ws,inputClubPres[i][1]); + cout << "Please enter the number of students in " << inputClubPres[0] << ": "; cin >> inputStuNum[i]; cout << endl; i++; @@ -39,7 +42,7 @@ void inputData(int inputStuNum[ARRAY_SIZE], string inputClubPres[ARRAY_SIZE][2]) cout << endl; } -void fundCalc(int calcNumStu[ARRAY_SIZE], int calcFund[ARRAY_SIZE]) +void fundCalc(int calcNumStu[], int calcFund[]) { int i = 0; @@ -50,13 +53,13 @@ void fundCalc(int calcNumStu[ARRAY_SIZE], int calcFund[ARRAY_SIZE]) } } -void tableDisp(int dispNumStu[ARRAY_SIZE], int dispFund[ARRAY_SIZE], string dispPresClub[ARRAY_SIZE][2]) +void tableDisp(int dispNumStu[], int dispFund[], string dispClubPres[][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 << dispClubPres[i][0] << '\t' << dispClubPres[i][1] << '\t' << dispNumStu[i] << '\t' << dispFund[i]; cout << endl; i++; } |