Test Results

I am disapointed in my resluts as I missed the requirment by 1 question. I nkow that I could do a lot better, however, I rushed through it as I forgot about doing it until the night it was due. I will not make this same mistake next time as I will make sure to start early so I do not have to rush through it.

Review of Dificult Question

Question 19: This option is incorrect. Since variable x stores the value 5, the expression x < 0 evaluates to false and the code in the first ELSE statement is executed. Since the variable y stores the value 10, the expression x > y evaluates to false, and “Hotel” cannot be displayed.

Question 23: This option is incorrect. Only one number should display.

Question 25: This option is incorrect. The value of the variable j starts at 1 and increases by 2. If is replaced with the expression j = 7, the expression will evaluate to true when j is 7 and the loop will end.]

Question 26: This option is incorrect. Since the parameter p is a positive integer, the robot can only end up in one of four possible squares in the grid: in the starting position, in the position two squares above facing up, in the position two squares above and two squares to the right facing right, or in the position two squares to the right facing left. The position shown is not one of the possible ending positions.

Question 31: This option is incorrect. If a is 30 and b is 50, the original code segment would result in final values of a equals 30 and b equals 70. However, changing line 7 to b, leftward arrow 20. would result in final values of a equals 30 and b equals 20.

Question 32: This option is incorrect. In program II, the value of i starts at n and finishes at 1, so that result stores the sum of n + (n - 1) + … + 3 + 2 + 1. This is the same as 1 + 2 + 3 + … + n.

Question 35: This option is incorrect. If the target value was the first element in a list of many elements, the linear search would require fewer comparisons.

Question 37: This option is incorrect. While the first five commands of this program match the top, bottom, and middle parts of the figure, the right-most part of the figure does not match the last line of the program: Draw (1, left).

Question 38: This option is incorrect. If the initial value of number is 3, the REPEAT UNTIL loop will reduce the value of number to 1, and then to –1, at which point the loop will terminate. The procedure would return false for a value of number greater than 2, which contradicts this statement.

Question 40: This option is incorrect. The robot turns right one, two, or three times and could end up in a square to the left of its initial position. It cannot end up in a square above its initial position.

Question 41: This option is incorrect. The statement Random (1 comma 5) could evaluate to 1, 2, 3, 4, or 5. There is a two out of five, or 40 percent, chance that it could evaluate to 1 or 2. If this happens, the value of sum is increased by 1, which simulates a person voting for the candidate. This does not match the goal of the program, which is to simulate an election in which a certain candidate is expected to receive 20 percent of the vote.

Question 48: This option is incorrect. Because line 1 and line 2 are not inside the FOR EACH loop, interchanging line 1 and line 2 will have no effect on the number of operations performed.