aboutsummaryrefslogtreecommitdiff
path: root/mod11a.cpp
diff options
context:
space:
mode:
authorTyler Taormina <[email protected]>2021-11-09 22:36:26 -0800
committerTyler Taormina <[email protected]>2021-11-09 22:36:26 -0800
commitf86fe8059b8ae06b748c0e20a80e45a98c2d19d1 (patch)
treefa445ca0b5bfbfcd45c64183c2decf661b159682 /mod11a.cpp
parentNovember 3, 2021 update to Lab 6. (diff)
downloadcst116-lab6-till-t-f86fe8059b8ae06b748c0e20a80e45a98c2d19d1.tar.xz
cst116-lab6-till-t-f86fe8059b8ae06b748c0e20a80e45a98c2d19d1.zip
Completed modules 11a and 11b.
Need last module.
Diffstat (limited to 'mod11a.cpp')
-rw-r--r--mod11a.cpp38
1 files changed, 21 insertions, 17 deletions
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 <<stringData[i][j] << setw(20) << stringData[i][j+1] << setw(20) << intData[i][j+1] << setw(20) << awardData[j] << endl;
+ cout << setw(20) << left << stringData[i][j] << setw(20) << left << stringData[i][j+1] << setw(20) << left << intData[i][j+1] << setw(20) << left << awardData[i] << endl;
}
}
}
-void readData(int intData[ARRAY_SIZE][2], string stringData[ARRAY_SIZE][2])
+int readData(int intData[ARRAY_SIZE][2], string stringData[ARRAY_SIZE][2])
{
- int again = 1, i = 0, num_stu = 0;
+ int again = 1, i = 0, num_stu = 0, counter = 0;
while (again && i < ARRAY_SIZE)
{
cout << "Enter the ID (0 to exit): ";
@@ -61,11 +64,13 @@ void readData(int intData[ARRAY_SIZE][2], string stringData[ARRAY_SIZE][2])
intData[i][1] = num_stu;
cout << endl;
i++;
+ counter++;
}
}
- cout << endl;
+ cout << endl;
+ return counter;
}
@@ -73,11 +78,10 @@ void readData(int intData[ARRAY_SIZE][2], string stringData[ARRAY_SIZE][2])
void calcData(int intData[ARRAY_SIZE][2], int awardData[ARRAY_SIZE])
{
int award = 75;
- int i = 0;
+ int i;
for (i = 0; i < ARRAY_SIZE; i++)
{
- int num_stu = intData[i][1];
- awardData[i] = num_stu * award;
+ awardData[i] = intData[i][1] * award;
}
}