Java program to determine greatest number among three input numbers.
Java program to determine greatest number among three input numbers.
import java.util.Scanner;
public class Largest {
public static void main(String[] args) {
int A,B,C;
Scanner obj1= new Scanner(System.in);
System.out.println("Enter the first number: ");
A=obj1.nextInt();
System.out.println("Enter the second number: ");
B=obj1.nextInt();
System.out.println("Enter the third number: ");
C=obj1.nextInt();
if(A>B && A>C){
System.out.println("A is the greatest number");
}
else if(B>A && B>C) {
System.out.println("B is the greatest number");
}
else {
System.out.println("C is the greates number");
}
obj1.close();
}
}
Output:
Enter the first number:
19
Enter the second number:
20
Enter the third number:
23
C is the greatest number
Comments
Post a Comment