| |
4. Using Java If-Statements: Help | page 12 of 31 |
- Task 1
Define local variables hot=100, cold=50, and temp=55. Print out the value of temp.
Use int for the type of each variable.
- Task 2
Use an if-statement to test for the temperature being exactly cold. If true, print "cold." If false (use an else-clause), test to see if temp is exactly hot. If so, print "hot".
Remember to use == to compare values, not =
- Task 3
Use an if-statement to test for the temperature being in between cold and hot. If it is, print "warm." Else, print "extreme temperature."
The binary or operator is ||
copyright 1996-2000 Magelang Institute dba jGuru
|