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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
|
Module 6: Lab 6
Tyler Taormina
CST 116
_______________________________________________________________________________
11a
10.10 Learn By Doing
pg 282-283
#1 for 10pts
CODE:
/*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;
}
}
RUN:
Enter the ID (0 to exit): 1
Enter the name of the club: Weenies
Enter the President of the club: Oliver
Enter the number of students in the club: 2
Enter the ID (0 to exit): 2
Enter the name of the club: Huskies
Enter the President of the club: Koda
Enter the number of students in the club: 3
Enter the ID (0 to exit): 3
Enter the name of the club: Ping Pong
Enter the President of the club: Tyler
Enter the number of students in the club: 1
Enter the ID (0 to exit): 4
Enter the name of the club: Video
Enter the President of the club: Mike
Enter the number of students in the club: 20
Enter the ID (0 to exit): 5
Enter the name of the club: Photo
Enter the President of the club: Sun
Enter the number of students in the club: 2
Enter the ID (0 to exit): 0
Student Club President Number of Students Award
=============================================================================
Weenies Oliver 2 150
Huskies Koda 3 225
Ping Pong Tyler 1 75
Video Mike 20 1500
Photo Sun 2 150
_______________________________________________________________________________
11b 10.14 Debugging Exercises
pg 289-292
#1 for 10pts
CODE:
// Tyler Taormina
// CST 116
// Module 11B Debugging Exercise
// pg 289-292
// #1 for 10pts
#include <iostream>
#include <iomanip>
using std::cin;
using std::cout;
using std::endl;
using std::setw;
void GetAndDisplayWelcomeInfo ( );
void FunctionOne ( int varX[], int varY[] );
void FunctionTwo ( int varX[], const int varY[], int varZ[] );
void PrintFunction ( const int varX[], const int varY[],
const int varZ[] );
const int SIZE = 10;
int main ( )
{
int varX[SIZE];
int varY[SIZE];
int varZ[SIZE]; // Notice how we used the const here!
// Breakpoint 1
// Put breakpoint on the following line
GetAndDisplayWelcomeInfo ( );
FunctionOne ( varX, varY );
// Breakpoint 3
// Put breakpoint on the following line
FunctionTwo ( varX, varY, varZ );
varZ[0] = -99;
PrintFunction ( varX, varY, varZ );
return 0;
}
void GetAndDisplayWelcomeInfo ( )
{
char name[2][20]; // First name in row 0, last name in row 1
cout << "Please enter your first name: ";
cin >> name[0];
cout << "\nPlease enter your last name: ";
cin >> name[1];
// Breakpoint 2
// Put breakpoint on the following line
cout << "\n\n\tWelcome " << name[0] << " " << name[1]
<< "!\n\t Hope all is well \n\n";
}
void FunctionOne ( int varX[], int varY[] )
{
for ( int x = 0; x < SIZE; x++ ) // NOTICE '<' NOT <=
// Breakpoint 4
// Put breakpoint on the following line
varX[x] = x;
for ( int x = 0; x < SIZE; x++ )
varY[x] = x + 100;
}
void FunctionTwo (int varX[], const int varY[], int varZ[] )
{
for ( int x = 0; x < SIZE; x++ ) // Notice the const SIZE here
varZ[x] = varX[x] + varY[x];
varX[1] = 99;
}
void PrintFunction ( const int varX[20], const int varY[20],
const int varZ[20] )
{
int x;
cout << " \t x \t y \t z\n\n";
for ( x = 0; x < SIZE; x++ )
cout << "\t" << setw ( 3 ) << varX[x]
<< "\t " << varY[x]
<< "\t " << varZ[x] << endl;
}
RUN:
Please enter your first name: tyler
Please enter your last name: taormina
Welcome tyler taormina!
Hope all is well
x y z
0 100 -99
99 101 102
2 102 104
3 103 106
4 104 108
5 105 110
6 106 112
7 107 114
8 108 116
9 109 118
_______________________________________________________________________________
11c
10.15 Programming Exercises
pg 292-293
#1 for 10pts
CODE:
RUN:
_______________________________________________________________________________
|