blob: e4e1919b639ccc8d6a8a7798e5752edba5017c8c (
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
|
#include <iostream>
using namespace std;
int main()
{
/*
int sel;
cout << "\t Student Grade Program\n"
<< "\t\t - Main Menu -\n\n";
cout << "\t1. Enter name\n"
<< "\t2. Enter test scores\n"
<< "\t3. Display test scores\n"
<< "\t9. Exit\n\n";
cout << "Please enter your choice from the list above : ";
cin >> sel;
switch (sel)
{
case 1:
cout << "\nSelected to enter name.\n";
break;
case 2:
cout << "\nSelected to enter test scores.\n";
break;
case 3:
cout << "\nSelected to display test scores.\n";
break;
default:
cout << "\nExiting Program.\n";
}
cout << "\nRedirecting. . .\n";
*/
//Set Variables
/*float rate;
float amount;
float interest;
int fee;
float total;
//Get Variables
cout << "Enter loan amount: ";
cin >> amount;
cout << "Enter interest rate: ";
cin >> rate;
//Validate
if (rate <= 0 || rate > 18)
{
cout << "Not a valid interest rate.\n";
return -1;
}
if (amount < 100 || amount > 1000)
{
cout << "Not a valid loan amount.\n";
return -2;
}
//Calc
if (amount <= 500 && amount > 100)
fee = 20;
else if (amount > 500 && amount <= 1000)
fee = 25;
else
{
cout << "Error calculating fee.\n";
return -3;
}
interest = amount * (rate / 100);
total = interest + fee;
//print
cout << "The loan has an amount of: " << amount << " and an interest rate of " << rate << endl
<< "The total payment of interest and fees is: " << total << endl;*/
// 7.2 #1
/*
// Account Varibles
float money;
int accounts;
// Switch Operator
int sel;
// Set Varibles
cout << "Number of accounts: ";
cin >> accounts;
cout << "Total money: ";
cin >> money;
// Calc
if (money >= 25000)
sel = 1;
if (money < 25000 && accounts > 1)
sel = 2;
if (money < 25000 && accounts == 1)
sel = 3;
if (money <= 10000)
sel = 4;
if (money <= 0 || accounts <= 0)
sel = 0;
cout <<"\n\n";
// Output
switch (sel)
{
case 1:
cout << "The membership level is Platinum with $" << money << " dollars and " << accounts;
if (accounts = 1)
cout << " account\n\n";
else
cout << " accounts\n\n";
break;
case 2:
cout << "The membership level is Gold with $" << money << " dollars and " << accounts;
if (accounts = 1)
cout << " account\n\n";
else
cout << " accounts\n\n";
break;
case 3:
cout << "The membership level is Silver with $" << money << " dollars and " << accounts;
if (accounts = 1)
cout << " account\n\n";
else
cout << " accounts\n\n";
break;
case 4:
cout << "The membership level is Copper with $" << money;
if (money > 1)
cout << " dollars and " << accounts;
else if (money < 1)
cout << " cents and " << accounts;
else
cout << " dollar and " << accounts;
if (accounts = 1)
cout << " account\n\n";
else
cout << " accounts\n\n";
break;
default:
cout << "Something went wrong. Neither the number of accounts or amount of money can be 0 or negative.\n\n";
}
*/
// 8.2
/*
int in;
cout << "Enter a number 1-50: ";
cin >> in;
if (in < 1)
{
cout << "Number cannot be 0 or negative";
return -1;
}
if (in > 50)
{
cout << "Number cannot be greater than 50";
return -2;
}
for (int c = in; c > 0; c--)
{
cout << c << ' ';
if (c % 10 == 1)
cout << endl;
}*/
// 8.3
/*
int in;
cout << "Enter a number 1-50: ";
cin >> in;
if (in < 1)
{
cout << "Number cannot be 0 or negative";
return -1;
}
if (in > 50)
{
cout << "Number cannot be greater than 50";
return -2;
}
do
{
cout << in << ' ';
if (in % 10 == 1)
cout << endl;
in--;
} while (in > 0);
*/
/*
int in;
cout << "Enter a number size for the right triangle: ";
cin >> in;
if (in < 1)
{
cout << "Number cannot be 0 or negative";
return -1;
}
for (int h = in; h > 0; h--)
{
for (int w = h; w > 0; w--)
cout << "\* ";
cout << endl;
}
*/
// 8.10
int num1 = 0,
num2 = 1,
num3;
int max;
cout << "What max number of the Fibonacci sequence would you like to display? ";
cin >> max;
cout << num1;
while (num2 < max)
{
cout << ", " << num2;
//Do the calc and shift the numbers over so calc can be done again.
num3 = num1 + num2;
num1 = num2;
num2 = num3;
}
return 0;
}
|