# Java program to Largest number among three numbers

Java Programming Java8Object Oriented Programming

Comparing three integer variables is one of the simplest programs you can write at ease.

•  Take two integer variables, say A, B& C
•  Assign values to variables
•  If A is greater than B & C, Display A is the largest value
•  If B is greater than A & C, Display B is the largest value
•  If C is greater than A & B, Display A is the largest value
•  Otherwise, Display A, B & C are not unique values

## Example

import java.util.Scanner;
public class LargestOfThreeNumbers {
public static void main(String args[]){
Scanner sc =new Scanner(System.in);
System.out.println("Enter 1st number :");
int a = sc.nextInt();
System.out.println("Enter 2nd number :");
int b = sc.nextInt();
System.out.println("Enter 3rd number :");
int c = sc.nextInt();

if ( a > b && a > c ){
System.out.println("Largest number is ::"+ a);
}else if ( b > a && b > c ){
System.out.println("Largest number is ::"+ b);
}else if ( c > a && c > b ){
System.out.println("Largest number is ::"+ c);
}else{
System.out.println("Cnnot validate");
}
}
}

## Output

Enter 1st number :
2
Enter 2nd number :
66
Enter 3rd number :
8
Largest number is ::66
Published on 26-Apr-2018 07:08:02