|
Lab 13 |
| . |
Four programs involving if-, else-, elseif-commands and int operators
and practicing using int operators.
----------------------------------------
Lab #13.1: Rewrite else-commands as elseif-commands
----------------------------------------
Rewrite the below program which (was shown on slide #4)
so that both of the else-commands are instead elseif-commands.
Your new program should produce the same result as the
original program.
if (guess != 1812) {
if (guess < 1812) {
JJS.outputString("guess higher");
} else {
JJS.outputString("guess lower");
}//endif
} else {
JJS.outputString("yes, correct");
}//endif
----------------------------------------
Lab #13.2: Letter Grade with one if-command
----------------------------------------
Given a single test score with a value between
zero and one hundred, assign a letter grade using
the typical 90-80-70-60 scale.
A: 90-100
B: 80-89
C: 70-79
D: 60-69
F: 59 or lower
Use only one if-command in your program.
----------------------------------------
Lab #13.3: Letter Grade without any elseif-commands
----------------------------------------
Rewrite the above program so that you do not use
any elseif-commands. You may use as many if-commands
as you wish.
----------------------------------------
Lab #13.4: Letter Grade from an average score
----------------------------------------
Rewrite the above program so that you assign a
letter grade to the average of three test scores.
|