Programming and Problem Solving with Java

(やまだぃちぅ) #1

198


3.If anif-elsestructure contains a nestedif-elsein each of its branches, as shown
below, how many different paths can be taken through the whole structure? (pp.
173–176)
if
if
else
else
if
else
4.What is the difference between theifand theif-elsecontrol structures? (pp.
170–173)
5.Which actions below are more like a sequence of ifs, and which are more like
nested ifs(mark the questions with S or N) (pp. 173–176)
a.Indicating your age in a list of ranges?
b.Marking all of your hobbies in a list
c.Checking off in a list all of the magazines you receive
d.Marking the items you want to order on a menu
e.Checking the box that indicates your marital status on a tax form
6.In a problem where you are determining the grade for a test score, given a series
of score ranges and corresponding grades, would it be more appropriate to use a
nested ifstructure or a sequence of ifs? (pp. 173–176)
7.What is the purpose of an algorithm walk-through? (pp. 190–193)
8.In what phase of the program development process should you carry out an exe-
cution trace? (pp. 190–193)
9.How does encapsulation make a class reusable? (pp. 177–179)
10.Write a Java expression that compares the variable letterto the constant ’Z’
and yields trueif letteris less than ’Z’. (pp. 156–158)
11.Write a Java expression that yields trueif letteris between ’A’and ’Z’,
inclusive. (pp. 156–158)
12.Write a Java statement that sets the variable valueto its negative if it is greater
than zero. (pp. 170–173)
13.Extend the statement in Question 12 so that it sets valueto 1 if it is less than or
equal to 0. (pp. 168–169)
14.On a telephone, each of the digits 2 through 9 has a segment of the alphabet as-
sociated with it. What kind of control structure would you use to decide which
segment a given letter falls into and to display the corresponding digit? (pp.
173–176)
Free download pdf