1// Java program to find largest of four numbers using nested if
2public class LargestNestedIfDemo
3{
4 public static void main(String[] args)
5 {
6 int num1 = 36, num2 = 35, num3 = 56;
7 if(num1 >= num2)
8 {
9 if(num1 >= num3)
10 {
11 System.out.println(num1 + " is largest number.");
12 }
13 else
14 {
15 System.out.println(num3 + " is largest number.");
16 }
17 }
18 else
19 {
20 if(num2 >= num3)
21 {
22 System.out.println(num2 + " is largest number.");
23 }
24 else
25 {
26 System.out.println(num3 + " is largest number.");
27 }
28 }
29 }
30}
1public class Main{public static void main(String[] args) {double a = 500, b = 1000, c = 1500;if( a >= b && a >= c)System.out.println(a + " largest number");else if (b >= a && b >= c)System.out.println(b + " largest number");elseSystem.out.println(c + " largest number");}}