Java Program to Find the Largest Among Three Numbers using input taken from users- (nested-if-else)


Program
import java.util.*; public class LargesAmongThree { public static void main(String[] args) { Scanner s=new Scanner(System.in); System.out.println("Enter the three number"); int a=s.nextInt(); int b=s.nextInt(); int c=s.nextInt(); if(a >= b) { if(a >= c) System.out.println(a + " is the largest number."); else System.out.println(c + " is the largest number."); } else { if(b >= c) System.out.println(b + " is the largest number."); else System.out.println(c + " is the largest number."); } } }
Input
Output

Similar Program

# Program Language
1 Java
2 Java
3 Java
4 Java
5 Java
6 Java
7 Java
8 Java
9 Java
10 Java
11 Java
12 Java
13 Java
14 Java
15 Java
16 Java
17 Java
18 Java
19 Java
20 Java
# Program Language