aboutsummaryrefslogtreecommitdiff
path: root/CST116F2021-Lab3/Joseph Ten Eyck-Lab3.cpp
blob: 3830fafd43c974dfd10e907330b2a2ffa5ee699c (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
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
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
//======================================================
//=      CODE FOR PROBLEM #1 ON PAGE 161 IS BELOW      =
//======================================================
// 
//#include <iostream> <iomanip>
//
//using std::cout;
//using std::cin;
//using std::endl;
//
//int main()
//{
//	short choice;
//
//	cout << "\t\t\tStudent Grade Program";
//	cout << "\n\t\t\t - Main Menu -";
//	cout << "\n\n\t\t1. Enter Name";
//	cout << "\n\t\t2. Enter test scores";
//	cout << "\n\t\t3. Display test scores";
//	cout << "\n\t\t9. Exit";
//	cout << "\n\n\tPlease enter your choice from the list above: ";
//
//	cin >> choice;
//
//	switch (choice)
//	{
//		case 1:
//			cout << "\n\tYou chose: Enter name" << endl;
//			break;
//		case 2:
//			cout << "\n\tYou chose: Enter test scores" << endl;
//			break;
//		case 3:
//			cout << "\n\tYou chose: Display test scores" << endl;
//			break;
//		case 9:
//			cout << "\n\tYou chose: Exit" << endl;
//			break;
//		default:
//			cout << "\n\tMenu choice does not exist" << endl;
//
//	}
//
//	return 0;
//}


//======================================================
//=      CODE FOR PROBLEM #2 ON PAGE 168 IS BELOW      =
//======================================================

//#include <iostream>
//
//using std::cout;
//using std::cin;
//using std::endl;
//
//int main()
//{
//
//	float rate,
//		loan_amount,
//		interest_amount,
//		interest_and_fees,
//		total_cost;
//	
//	short fee = 0;
//
//
//	cout << "\t\t     =========================\n"; 
//	cout << "\t\t\t= Loan Calculator =";
//	cout << "\n\t\t     =========================\n";
//
//	cout << "\n\n\t\tEnter loan amount: ";
//	cin >> loan_amount;
//
//	cout << "\n\t\tEnter loan rate percent: ";
//	cin >> rate;
//
//
//	if (rate < 1 || rate > 18)
//	{
//		cout << "\n\n\tERROR: Interest rate is not between 1% and 18%" << endl;
//	}
//
//	else if (loan_amount < 100 || loan_amount > 1000)
//	{
//		cout << "\n\n\tERROR: Loan amount is not between $100 and $1,000" << endl;
//	}
//
//	else
//	{
//
//		if (loan_amount <= 500)
//			fee = 20;
//
//		else
//			fee = 25;
//
//
//		interest_amount = loan_amount * rate * 0.01;
//
//		interest_and_fees = interest_amount + fee;
//
//		total_cost = loan_amount + interest_and_fees;
//
//
//		cout << "\n\n\tRequested loan amount: $" << loan_amount;
//		cout << "\n\tInterest rate: " << rate << "%";
//		cout << "\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
//		cout << "\n\tInterest amount: $" << interest_amount;
//		cout << "\n\tFee: $" << fee;
//		cout << "\n\n\tSum of interst and fees: $" << interest_and_fees;
//		cout << "\n\n================================================================";
//		cout << "\n\tTotal Cost: $" << total_cost << "\n\n";
//	}
//	
//
//	return 0;
//}


//======================================================
//=      CODE FOR PROBLEM #1 ON PAGE 177 IS BELOW      =
//======================================================

//#include <iostream>
//
//using std::cout;
//using std::cin;
//using std::endl;
//
//int main()
//{
//
//	int number = 0;
//
//	cout << "\n\tEnter an integer between 1 and 50: ";
//	cin >> number;
//
//	cout << "\n";
//
//	if (number < 1 || number > 50)
//		cout << "\nERROR: Number must be between 1 and 50\n\n";
// 
//	else
//	{
//		cout << number << " ";
//
//		while (number > 0)
//		{
//			--number;
//
//			if (number % 2 == 0)
//				cout << number << " ";
//
//			else
//				cout << " ";
//
//		}
//		cout << "\n\n" << endl;
//	}
//
//	return 0;
//}


//======================================================
//=      CODE FOR PROBLEM #1 ON PAGE 179 IS BELOW      =
//======================================================

//#include <iostream>
//
//using std::cout;
//using std::cin;
//using std::endl;
//
//int main()
//{
//	int number = 0;
//
//	cout << "\n\tEnter an integer between 1 and 50: ";
//	cin >> number; 
//
//	cout << "\n";
//
//
//	do
//		if (number < 1 || number > 50)
//		{
//			cout << "\n\nERROR: Number must be between 1 and 50\n";
//
//			cout << "\n\tEnter an integer betwen 1 and 50: ";
//			cin >> number;
//
//			cout << "\n";
//		}
//		else
//			cout << "\n\n";
//	while (number < 1 || number > 50);
//
//
//	cout << number << " ";
//
//		while (number > 0)
//		{	
//			--number;
//
//			if (number % 2 == 0)
//				cout << number << " ";
//
//			else
//				cout << " ";
//
//		}
//		cout << "\n\n" << endl;
//
//	return 0;
//}


//======================================================
//=      CODE FOR PROBLEM #1 ON PAGE 184 IS BELOW      =
//======================================================

//#include <iostream>
//
//using std::cout;
//using std::cin;
//using std::endl;
//
//int main()
//{
//
//	int assignments = 0;
//	int assignments_initial = 0;
//	int sum = 0;
//
//	cout << "\n\t\tEnter number of assignments: ";
//	cin >> assignments;
//
//	assignments_initial = assignments;
//
//	cout << "\n\n";
//
//	for (assignments; assignments > 0; assignments--)
//	{
//		int score = 0;
//
//		cout << "\tEnter assignment " << assignments << " score: ";
//		cin >> score;
//
//		cout << "\n";
//
//		sum += score;
//	}
//
//	float avg = (float)sum / (float)assignments_initial;
//
//	cout << "\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n";
//	cout << "\n\t\tAverage assignment score: " << avg;
//	cout << "\n\n" << endl;
//
//	return 0;
//}


//======================================================
//=      CODE FOR PROBLEM #3 ON PAGE 192 IS BELOW      =
//======================================================

//#include <iostream>
//
//using std::cout;
//using std::cin;
//using std::endl;
//
//int main()
//{
//	int ending_number = 0;
//	int current_number = 1;
//	int previous_number = 0;
//	int hold = 0;
//
//	cout << "\n\t\t==================================";
//	cout << "\n\t\t== Fibonacci sequence generator ==";
//	cout << "\n\t\t==================================";
//	cout << "\n\n\t";
//
//	cout << "Enter ending number: ";
//	cin >> ending_number;
//
//	cout << "\n\n";
//
//	if (ending_number < 1)
//		cout << "ERROR: Ending number must be 1 or greater";
//
//	else
//
//		while (current_number <= ending_number)
//		{
//			cout << current_number << " ";
//
//			hold = current_number;
//			current_number += previous_number;
//			previous_number = hold;
//		}
//
//	cout << endl;
//
//	return 0;
//}