Fill in the two blanks so that the nested if's make the correct choice.
See below.
if ( count+1 == 2 ) suffix = "nd"; else if ( count+1 == 3 ) suffix = "rd"; else suffix = "th"; System.out.println( "Enter the " + (count+1) + suffix + " integer (enter 0 to quit):" );
The first if
makes a
choice between its true branch and its false branch.
Its false branch is complicated, but that doesn't matter.
Each branch of an if
statement can be as complicated as needed.
The fragment shows
the first if's
true branch in blue
and its false branch in red.
For example, if
(count+1)
is equal to 2,
the true branch is picked.
The variable suffix
gets "nd",
and the false branch is completely skipped.
The expression
(count+1)
is always greater than 1.
For each of the following possible values of
(count+1)
which string will be assigned to suffix
?