Tutorial 3 Flow of Control (Selection)
Tutorial 3 Flow of Control (Selection)
b.
if (x > y > z)
System.out.println("x is the largest number");
c.
String s1, s2;
if (s1==s2)
System.out.println("They are equal strings.");
else (s1!=s2)
System.out.println("They are not equal strings.");
d.
if x>0 or y>0;
System.out.println("Either x or y is positive");
3. Write the output for the following statements when x=9 and y=10
a.
if (x < 10)
if (y > 10)
System.out.println("*****");
else
System.out.println("#####");
System.out.println("$$$$$");
b.
if (x < 10) {
if (y < 10)
System.out.println("*****");
else{
System.out.println("#####");
System.out.println("$$$$$");
}}
c.
if (x < 10) {
if (y < 10)
System.out.println("*****");
System.out.println("#####");
}
else {
System.out.println("$$$$$");
}
d.
if (x > 10) {
if (y > 10) {
System.out.println("*****");
System.out.println("#####"); }
else
System.out.println("$$$$$");
}
4. Write the java statements that used the if statement to find the biggest number among
three given integers.
5. Write the java statements that determine whether the Leap year. A Leap year is
divisible by 4 but not by 100. However, a Leap year is also divisible by 400.