aboutsummaryrefslogtreecommitdiff
path: root/CST116F2021-Lab2/Lab2-Textual_work.txt
blob: e3548f14a4575b4702ca7b2793545698b0d86ff1 (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
By Jordan Harris-Toovy for OIT's CST116-01P course lab 2, October 2021

3a:
[4.1]
	1) Good - Float
	2) Bad - Multiple characters within ' ' char designator, should be "Hello"
	3) Good - String
	4) Good - String
	5) Good - Character
	6) Bad - Not a literal (did they mean 0xA?) , should be 'A'
	7) Bad - Almost a string, but no ending ", should be "Marcus"

[4.3]
	a) 0 to 2^8 -1
	b) 0 to 2^16 - 1
	c) 0 to 2^32 - 1
	d) -(2^63) to +(2^63 - 1)
	e) -(2^15) to +(2^15 - 1)
	
[6.1]
	1) Invalid - 5x is not a valid multiplication - should be: y = 5 * x + 1;
	2) Invalid - four errors: X� is not in ASCII, 5x is not a valid multiplication, the equality is on the right, and the equality is not 'pointing' into a variable - this mathematical expression cannot be implemented like this in C++
	3) Valid 
	4) Invalid - the equality is not 'pointing' into a variable (0 is not an accessible memory location anyway) - this mathematical expression cannot be implemented like this in C++



3b:
	1) The issue here is that +6% is x1.06 not x0.06!
	
Display "Enter old wage: "
Read Old_wage

New_wage = Old_wage * 1.06

Display Old_wage
Display " +6% = "
Display New_wage

	2) There are three problems with this code: One is that the test scores are scaled twice (once before averaging, once during the final average), another is that the final scaling factor for the tests is wrong (15*3=45 not 40), and finally the variable names are not consistent (E.G.: Assignment_avg and Assign_avg)

Display "Enter assignment average: "
Read Assignment_avg

Display "Enter Test 1: "
Read Test1

Display "Enter Test 2: "
Read Test2

Display "Enter Test 3: "
Read Test3

Display "Enter Final: "
Read Final

Test_avg = ( Test1 + Test2 + Test3 ) / 3
Class_score = Assign_avg * 0.3 + Test_avg * 0.45 + Final *0.25

Display "Final score: "
Display Class_score



4a:
	1) a = 25
	2) a = 30
	3) a = 35
	4) a = 0
	5) a = 1
	6) a = 0.6
	7) Invalid syntax, would be a = 4 if rearranged