Unit 3 Sections 12-13 Hacks
Homework for Unit 3 Sections 12-13.
3.12 Hacks Part 1
Problem 1:
Answer: PROCEDURE calcAvgSpeed (distance, time) { DISPLAY (distance/time) }
This is the answer because both distance and time are needed and the value of distance/time needs to be calculated to determine the average speed.
Problem 2:
Answer: True, nothing will be displayed
Even though volume have the value of IM MAD!!!, nothing will be displayed because they is no DISPLAY() statement.
Problem 3:
Answer: The correct answers are code snippets 1 and 4.
Code snippet 1 is correct because it directly adds the carbon footprints from each flight to get the total carbon footprint.
Code snippet 4 is also correct because it assigns each carbon footprint to a variable which are then added together to get the total carbon footprint.
3.12 Hacks Part 2
Problem 1:
Answer: The value of a is 729.
First, the value of b is found by multiplying 9 and 9 which is 81. Next, the value of a is found by multiply the value of b and c together which is 81 x 9 which is 729.
Problem 2:
“cost ⟵ 173 tax - 10%” was written poorly and was very confusing. At first I thought cost was assigned to the entire value on the right. But after a long time of getting confused, I realized cost was assigned to 173 and tax was assigned to 10%.
Answer: The cost is 190.3
First, we know that temp is 100 + percentTaxed which is 110. Next, temp is assigned to temp/100 which is 110/100 which is 1.1. Lastly, cost is equal to the previously given value of cost multiplied by the new value for temp which gives us a value of 190.3 (173 x 1.1) for cost.
Problem 3:
Answer: The temperature in celsius is about 39.4 degrees Celsius.
First, Celsius is set to the value of temperature - 32 which is 71. Next, Celsius is set to the value of Celsius x 5/9 which is about 39.4.
3.13 Hacks Parts 1 and 2
Problem 1:
PROCEDURE CurrentHighest(currentrbyards, totalGames, toprbyardspg) {
currentrbyardspg <– currentrbyards/totalGames
IF currentrbyardspg > toprbyardspg {
toprbyardspg <– currentrbyardspg
}
return(toprbyardspg)
}
DISPLAY(CurrentHighest(1260, 12, 100))
Problem 2:
PROCEDURE MoveAPlus {
move_forward()
rotate_left()
move_forward()
move_forward()
rotate_right()
move_forward()
move_forward()
move_forward()
rotate_left()
move_forward()
move_forward()
rotate_left()
move_forward()
move_forward()
rotate_right()
move_forward()
rotate_left()
move_forward()
move_forward()
}
Problem 3:
Answer: B. PROCEDURE MyList
This is the correct answer because “procedure” needs to be in all caps and only part of the name of the procedure should be in caps.
Problem 4:
Assuming beach ball starts facing forward:
PROCEDURE MoveBeachBall {
rotate_left()
move_forward()
rotate_right()
repeat 6 times {
move_forward()
}
rotate_left()
move_forward()
move_forward()
}