import java.util.Scanner;
class G
{
public static void main(String args[])
{
Scanner in = new Scanner(System.in);
int a,b,c;
System.out.println("Enter the three numbers ");
a=in.nextInt();
b=in.nextInt(); // taking three inputs from user
c=in.nextInt();
if(a!=b&&b!=c&&c!=a){ // Checking whether there is more than one same input
if(a>b&&a>b) //Checking for first number
System.out.println(a+" is greatest");
else if(b>a&&b>c) //Checking for second number
System.out.println(b+" is greatest");
else // In case all conditions are false the third condition becomes trueSystem.out.println(c+" is greatest");
}
else
System.out.println("One or more numbers are equal ;try again ");
}
}
No comments:
Post a Comment