From f86fe8059b8ae06b748c0e20a80e45a98c2d19d1 Mon Sep 17 00:00:00 2001 From: Tyler Taormina Date: Tue, 9 Nov 2021 22:36:26 -0800 Subject: Completed modules 11a and 11b. Need last module. --- mod11a.cpp | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) (limited to 'mod11a.cpp') diff --git a/mod11a.cpp b/mod11a.cpp index 975c772..be874cd 100644 --- a/mod11a.cpp +++ b/mod11a.cpp @@ -10,41 +10,44 @@ using namespace std; #define ARRAY_SIZE 10 -void readData(int[ARRAY_SIZE][2], string[ARRAY_SIZE][2]); +int readData(int[ARRAY_SIZE][2], string[ARRAY_SIZE][2]); -void printData(int[ARRAY_SIZE][2], string[ARRAY_SIZE][2], int[ARRAY_SIZE]); +void printData(int[ARRAY_SIZE][2], string[ARRAY_SIZE][2], int[ARRAY_SIZE], int); void calcData(int[ARRAY_SIZE][2], int[ARRAY_SIZE]); int main() { - int award[ARRAY_SIZE]{}; - int id_numStu[ARRAY_SIZE][2]{}; - string pres_club[ARRAY_SIZE][2]{}; - readData(id_numStu, pres_club); - printData(id_numStu, pres_club, award); + int COUNTER; + int award[ARRAY_SIZE]; + int id_numStu[ARRAY_SIZE][2]; + string pres_club[ARRAY_SIZE][2]; + COUNTER = readData(id_numStu, pres_club); calcData(id_numStu, award); + printData(id_numStu, pres_club, award, COUNTER); } -void printData(int intData[ARRAY_SIZE][2], string stringData[ARRAY_SIZE][2], int awardData[ARRAY_SIZE]) +void printData(int intData[ARRAY_SIZE][2], string stringData[ARRAY_SIZE][2], int awardData[ARRAY_SIZE], int ctr) { - cout << setw(10) << "Student Club" << setw(10) << " President" << setw(10) << " Number of Students" << setw(10) << " Award\n" << endl; + cout << setw(20) << left << "Student Club" << left << setw(20) << "President" << setw(20) << left << "Number of Students" << setw(20) << left << "Award" << endl; // Headings for the columns ^^ + cout << "=============================================================================" << endl; - for (int i = 0; i < ARRAY_SIZE; i++) + + for (int i = 0; i < ctr; i++) { for (int j = 0; j < 1; j++) { - cout <