For this exercise you will define some variables representing
temperatures (in Fahrenheit) and print out whether or not a
termperature is hot, cold, warm, or extreme.
[If you are using IBM's VisualAge for Java for this exercise,
then use the scrapbook to type and test your code (without a
main() method etc...), thus, avoiding the need to fill in the
skeleton code, compile, and run from the command line.].
For more help with exercises, see About The Exercises
Prerequisites
Tasks
-
Task 1
Define local variables hot=100, cold=50, and temp=55. Print out the value of temp.
-
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".
-
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."
Help for each of these tasks can be found on the next page.
copyright 1996-2000 Magelang Institute dba jGuru