java program to find the largest in three numbers using nested if

Solutions on MaxInterview for java program to find the largest in three numbers using nested if by the best coders in the world

showing results for - "java program to find the largest in three numbers using nested if"
Betty
14 Apr 2017
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}
Mia
10 Sep 2017
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");}}