blob: dbbc8d46fbcfdfa2bc650416ff18d634c9fb9c71 (
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
|
CST116
Module 2: Lab 2
3a 4.1 #1 - 7
1. Legal – Numeric Literal
2. Illegal
3. Legal – String literal
4. Illegal
5. Illegal
6. Illegal
7. Illegal
4.3 #3
a.There should only be one “int” and it should be at the beginning(i.e. int a, b;)
b.a can’t be signified as another variable(b) because b is not signified first
(i.e.b = 0; a = b;)
c.b should be declared on a different line(i.e. int a = 0; int b = 3.5;)
d.Instead of quotations, it should be an apostrophe(ex. char grade = ‘A’;)
e.Instead of char it should be int because char uses a string of letters(ex. int c = 1;)
f.
g.Should not be a string, should be a character, also use apostrophe
(ex. char x = ‘T’;)
6.1 #1 - 4
1. Invalid.Should be ‘y = 5 * x + 1; ’
2. Invalid.Should be ‘x * x + 2 * x + 1 = 0; ’
3. Valid
4. Invalid.There cannot be a 0 starting the expression
3b 4.12 #1 - 2
1. He did the math wrong.Change .06 with 1.06
2. The class score doesn’t add up to 100 % (.2 + .4 + .25 = .85)
3c 4.13 #2 - 3
2. #include <iostream>
Using std::cout
Int main()
{
Char ascii = 67;
Cout << ascii << ‘\n’;
Ascii = 43;
Cout << ascii << ‘\n’;
Cout << ascii << ‘\n’;
Return 0;
}
3. #include <stdio.h>
int main()
{
int age_of_person;
float year = 365, days;
//ask for age
printf("\nHow old are you: ");
//process age
scanf_s(" %d", &age_of_person);
//convert years into days
days = age_of_person * year;
//print answer
printf("\nYour age in days is: %f", days);
return 0;
4a 5.4 #1
1.
#include <iostream>
#include <stdlib.h>
#include <iomanip>
float temperature;
using namespace std;
int main()
{
//taking temperature and storing
printf("\nWhat is your temperature? ");
cin >> temperature;
//listing temperature
cout << "\nYour Temperature is: ";
cout.setf(ios::fixed);
cout << setprecision(6);
cout << temperature << endl;
return 0;
}
6.3 #1 - 7
1. 25
2. 30
3. error ? a is already defined
corrected is a = 5
b = a + ( 5 + 10 ) * 2;
4. 0
5. 1
6. error ? both operands have to be an integer
corrected is a = 5 % 2;
7. 4
4b 5.9
1.
#include <iostream>
#include<iomanip>
using std::cout;
using std::cin;
using std::endl;
int main()
{
float money = 123.45F;
float raise;
cout << "you have $";
cout << money << endl;
//breakpoint 1
//put a breakpoint on the following line
cout << "enter percent raise: ";
cin >> raise;
money = money * raise;
cout << "After your raise you have $";
cout << money << endl;
return 0;
}
5.10 #1
1.
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
int main()
{
double ProductionHours;
double PreProductionHours;
double ProducersHours;
double ProductionCost;
double PreProductionCost;
double ProducersCost;
double TotalCost;
double PRODUCTIONRATE{};
double PRE_PRODUCTION_RATE{};
double PRODUCERS_RATE{};
double ProducerHours{};
cout << "Enter Production Hours: ";
cin >> ProductionHours;
cout << "\nEnter Pre-Production Hours: ";
cin >> PreProductionHours;
cout << "\nEnter Producers Hours: ";
cin >> ProducersHours;
ProductionCost = ProductionHours * PRODUCTIONRATE;
PreProductionCost = PreProductionHours * PRE_PRODUCTION_RATE;
ProducersCost = ProducerHours * PRODUCERS_RATE;
TotalCost = ProductionCost + PreProductionCost + ProducersCost;
cout << "\n\tCar Dealership Bill\n\"";
cout << "\n\nProduction Cost : ";
cout << ProductionCost;
cout << "\n\nPre - Production Cost : ";
cout << PreProductionCost;
cout << "\n\nProducers Cost : ";
cout << ProducersCost;
cout << "\n\nWeekly Total Cost : ";
cout << TotalCost << endl;
return 0;
}
|