Conditional Solutions
Conditional Solutions
Solution 1:
import java.util.*;
if (x > 0) {
System.out.println("x is greater than 0");
} else {
System.out.println("x is less than or equal 0");
}
}
}
Solution 2:
public class Solution{
public static void main(String[] args) {
double temp = 103.5;
Solution 3:
import java.util.*;
switch(week) {
case 1:
System.out.println("Monday");
break;
case 2:
System.out.println("Tuesday");
break;
case 3:
System.out.println("Wednesday");
break;
case 4:
System.out.println("Thursday");
break;
case 5:
System.out.println("Friday");
break;
case 6:
System.out.println("Saturday");
break;
case 7:
System.out.println("Sunday");
break;
default:
System.out.println("Invalid input! Please enter week number between
1-7.");
}
}
}
Solution 4:
Value of x = false & y = 63..
Solution 5:
import java.util.*;
boolean x = (year % 4) == 0;
boolean y = (year % 100) != 0;
if (x && (y || z)) {
System.out.println(year + " is a leap year");
} else {
System.out.println(year + " is not a leap year");
}
}
}
https://t.me/+QGUyTripaP4zNTcx
https://telegram.me/+QGUyTripaP4zNTcx