Page 85 - Introduction to Programming with Java: A Problem Solving Approach
P. 85
Review Questions §2.2 Output
1. Describe what this statement does: print “user name = ” userName
§2.3 Variables
2. Provide an appropriate variable name for a variable that holds the total number of students.
§2.4 Operators and Assignment Statements
3. Write a line of pseudocode that tells the computer to assign distance divided by time into a speed
variable.
§2.5 Input
4. Write a line of pseudocode that tells the computer to put a user entry into a variable called height.
§2.6 Flow of Control and Flowcharts
5. What are the three types of control flow described in this chapter?
6. Looping is appropriate whenever the next thing done is something previously done. (T / F)
§2.7 if Statements
7. Consider the following pseudocode:
if it is night, set spAepedaLigmiot to 5P5;DF Enhancer otherwise, set speedLimit to 65.
Suppose the value of the variable, night, is “false.” After this code runs, what should be the value of the
variable, speedLimit?
8. The above pseudocode does not have the exact form suggested in the text. Is that OK?
9. Draw a flowchart that implements this logic:
If the temperature is greater than 10˚C and it’s not raining, print “walk.” Otherwise, print “drive.”
10. Provide a solution to the previous problem in the form of pseudocode.
§2.8 Loops
11. Where is a while loop’s terminating decision made?
12. When a while loop terminates, what executes next?
13. Is it possible for a while loop to have an infinite number of iterations? 14. Is it possible for a while loop to have zero iterations?
§2.9 Loop Termination Techniques
15. What are the three loop termination techniques described in this chapter?
16. A sentinel value is used to do which of the following? a) Specify the first value printed.
b) Print an error message.
c) Signal the end of input.
§2.10 Nested Looping
17. How does the form of pseudocode we use in most of this chapter differentiate an inner loop from an outer loop?
Review Questions 51