![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
Suppose, for example, that you want to write a program that displays a
message that depends on the length of a movie in minutes. Specifically, if
the length is greater than 90 minutes, you want your program to display
It is long!
, and if the length is less than 60 minutes, you want
your program to display It is short!
.
One solution is to write a program that uses if
statements in
which the embedded statements are display statements:
public class Demonstrate { public static void main (String argv[]) { int length = 95; if (length < 60) System.out.println("It is short!"); if (length > 90) System.out.println("It is long!"); } } --- Result --- It is long!