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