Skip to content

Largest Among Three Numbers

Choose a tag to compare

@divyaskesavan divyaskesavan released this 22 Feb 15:59
· 2 commits to main since this release
24f788f

import java.util.Scanner;

public class LargestNumber {
public static void main(String[] args) {
int a, b, c;
Scanner sc = new Scanner(System.in);
System.out.println("Enter Three Numbers");
a = sc.nextInt();
b = sc.nextInt();
c = sc.nextInt();
if (a > b && a > c) {
System.out.println("The largest number is: " + a);
} else if (b > a && b > c) {
System.out.println("The largest number is: " + b);
} else if (c > a && c > b) {
System.out.println("The largest number is: " + c);
} else if (a == b && b == c) {
System.out.println("All numbers are equal");
} else {
System.out.println("Invalid Input");
}
}
}