aboutsummaryrefslogtreecommitdiff
path: root/CST116F2021-Lab6/CST116F2021-Lab6.cpp
blob: 4ead57c579ba85071d1366137bfc6ddf9670e06b (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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
// CST116F2021-Lab6.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <string>
#include <iomanip>
#include <cstring>

using namespace std;
#define ARRAY_SIZE 10
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);
	tableDisp(student_number, fund_value, club_pres_name);
}


void inputData(int inputStuNum[], string inputClubPres[][2])
{
	int  i = 0;

	while (i < ARRAY_SIZE)
	{
		cout << "Please enter the club name: ";
		getline(cin >> ws,inputClubPres[i][0]);
		cout << "Please enter the club president: ";
		getline(cin >> ws,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[], int calcFund[])
{
	int i = 0;

	while (i < ARRAY_SIZE)
	{
		calcFund[i] = calcNumStu[i] * 75;
		i++;
	}
}

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 << dispClubPres[i][0] << '\t' << dispClubPres[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;
//}