Page 89 - Introduction to Programming with Java: A Problem Solving Approach
P. 89
if temperature is greater than 10 if raining equals “n”
print “walk” else
print “drive”
11. A while loop’s terminating decision is made at the beginning of the loop.
12. After a while loop terminates, the next thing to execute is the first statement after the end of the loop.
13. Yes.
14. Yes.
15. The three loop termination techniques described in this chapter are: counter, user query, and sentinel value.
16. A sentinel value is used to: c) signal the end of input.
17. The inner loop is entirely inside the outer loop. The entire inner loop is shifted to the right compared to the outer loop.
18. d) All of above. Tracing shows sequence of execution, helps debug, and highlights initialization and termination errors.
19. Bowling Score algorithm trace:
input 94 104
114 Apago PDF Enhancer 1
Review Question Solutions 55
line#
score
totalScore
count
avg
output
1
0
2
0
3
Enter score (-1 to quit):
4
94
6
94
7
1
8
Enter score (-1 to quit):
9
104
6
198
7
2
8
Enter score (-1 to quit):
9
114
6
312
7
3
8
Enter score (-1 to quit):
9
-1
10
104
11
Average score is 104