blob: 7c242fc0b6579921336fdcc4098fd2f5c0129ed3 (
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
|
CST116 C++
6.4 5a pg 126 #1
1.
0
2
3
2
1
7.1 pg 148 #1-6
1. The sign is reversed. it should be <=
int_exp1 <= int_exp2
2. There should be 2 equal signs
int_exp1 == int_exp2
3. ! should be on the other side
int_exp1 != int_exp2
4. Cant compare a string literal using relational quotes
char_exp == 'A'
5. This is correct
6. Has to have int_exp1 (on each side of operator)
int_exp1 < 2 && int_exp1 > -10
7.2 pg 155 #1
#include <iostream>
#include<math.h>
#include<iomanip>
#include <string>
using std::cout;
using std::endl;
using std::string;
int main()
{
int money;
int accounts;
//take the number of accounts
cout << "How many accounts do you have with us today?\n";
std::cin >> accounts;
//take the money amount
cout << "How much money do you have in your account(s)?\n $";
std::cin >> money;
//if x>=25,000 is platinum
//if 10,000<x<25,000 and 2 accounts is gold
// if x>10,000 but only 1 account is silver
//if x<=10,000 is copper
if ((money >= 25000) & (accounts == 2)) {
cout << "You are a Platinum member!";
}
else if ((money >= 25000) & (accounts == 1)) {
cout << "You are a Platinum member!";
}
else if (((10000 < money) && (money < 25000)) & (accounts > 1)) {
cout << "You are a Gold member!";
}
else if (((10000 < money) && (money < 25000)) & (accounts == 1)) {
cout << "You are a Silver member";
}
else if ((money <= 10000) & (accounts == 2)) {
cout << "You are a Copper member";
}
else if ((money <= 10000) & (accounts == 1)) {
cout << "You are a Copper member";
}
return 0;
}
5b 7.4 pg 161 #1
|