aboutsummaryrefslogtreecommitdiff
path: root/mod11a.cpp
blob: be874cde7561843b7c948cdbcdf27ddeeeb6f63d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/*Tyler Taormina
 *Module 11a
 *Matrix Practice
 */

#include <iostream>
#include <cstring>
#include <iomanip>
using namespace std;

#define ARRAY_SIZE 10

int readData(int[ARRAY_SIZE][2], string[ARRAY_SIZE][2]);

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 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], int ctr)
{
    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 < ctr; i++)
    {
        for (int j = 0; j < 1; j++)
        {
            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;
        }
    }

}

int readData(int intData[ARRAY_SIZE][2], string stringData[ARRAY_SIZE][2])
{
    int again = 1, i = 0, num_stu = 0, counter = 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 of the club: ";
            getline( cin >> ws, stringData[i][0]);
            cout << "Enter the President of the club: ";
            getline( cin >> ws, stringData[i][1]);
            cout << "Enter the number of students in the club: ";
            cin >> num_stu;
            intData[i][1] = num_stu;
            cout << endl;
            i++;
            counter++;
        }


    }
    cout << endl;
    return counter;

}


void calcData(int intData[ARRAY_SIZE][2], int awardData[ARRAY_SIZE])
{
    int award = 75;
    int i;

    for (i = 0; i < ARRAY_SIZE; i++)
    {
        awardData[i] = intData[i][1] * award;
    }
}