creation: 08/08/99
Instructions: This is an ungraded fill-in-the-blank exercise. Each question consists of a sentence with one or two words left out. A button represents the missing word(s). For each question, think of the word or phrase that should fill each blank, then click on the buttons to see if you are correct. No grade is calculated for this exercise.
Rule for Matching if and else: Within each pair of matching braces: start with the firstif
and work downward. Eachelse
matches the closest previous unmatchedif
. Anif
matches only oneelse
and anelse
matches only oneif
.
1. Click on the
that matches the IF in
capitals (of course, in a real Java program the if
has to be lower case.)
2. Click on the that matches the IF in capitals.
IF ( val == 34 ) { sum = sum + val; val = 0; next= 5; } { sum = sum - val; if ( sum < limit ) flag = true; flag = false; } |
IF ( val == 34 ) { if ( sum < limit ) sum = sum + val; } { sum = sum - val; val = sum + 1; } |
if ( val == 34 ) { sum = sum + val; val = 0; next= 5; } { sum = sum - val; IF ( sum < limit ) flag = true; flag = false; } |
IF ( val == 34 ) { if ( sum < limit ) sum = sum + val; if ( val >= limit ) val = sum - limit; val = 0; } if ( val = -12 ) sum = 0; limit = 88; |
End of the Exercise. If you want to do it again, click on "Refresh" in your browser window. Click here to go back to the main menu.