Sun Java Solaris Communities My SDN Account Join SDN
 
Tutorials & Code Camps

jGuru: Help: Using Java If-Statements

 

by jGuru

[Exercise | API Docs | Short Course| Exercises]

Help is available for each task.


    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 jGuru.com. All Rights Reserved.