blob: 77b28a7705efe6d4bf76078cb4c75c1d4e6e36bc (
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
|
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
#include <iostream>
#include <iomanip>
using std::endl;
using std::cout;
int main()
{
int selection;
cout << "Student Grade program\n -Main Menu- \n\n1. Enter Name\n2. Enter test scores\n3. Display test scores\n9. Exit\n\nPlease enter your choice from the list above\n\n";
std::cin >> selection;
switch (selection)
{
case 1 :
cout << "\n\nYour choice is: Enter Name?\n\n";
break;
case 2:
cout << "\n\nYour choice is: Enter Test Scores?\n\n";
break;
case 3:
cout << "\n\nYour choice is: Display Test Scores?\n\n";
break;
case 9:
cout << "\n\nYour choice is: to Exit?\n\n";
break;
default:
cout << "\n\nYour selection is invalid... Try again\n\n";
}
}
|