import java.util.Scanner;
class large
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
int a,b,c;
System.out.println("Enter the Three values:");
a=sc.nextInt();
b=sc.nextInt();
c=sc.nextInt();
if(a>b && a>c)
System.out.println("First Integer is greater!");
else if(b>a && b>c)
System.out.println("Second Integer is greater!");
else if(c>a && c>b)
System.out.println("Third Integer is greater!");
else
System.out.println("Entered integers are not distinct!");
}}
class large
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
int a,b,c;
System.out.println("Enter the Three values:");
a=sc.nextInt();
b=sc.nextInt();
c=sc.nextInt();
if(a>b && a>c)
System.out.println("First Integer is greater!");
else if(b>a && b>c)
System.out.println("Second Integer is greater!");
else if(c>a && c>b)
System.out.println("Third Integer is greater!");
else
System.out.println("Entered integers are not distinct!");
}}
The Scanner class is imported to enable the reading from the keyboard. We use three Integer variables a,b and c. Next line we accept values from the user. We check whether a is greater than b and a is greater than c? if it is true then a is greater. Else if b is greater than a and b is greater than c? if it is true then b is greater. Else if c is greater than a and c is greater than b? if the condition yields true! c is greater. If none of the above conditions return true, Then the final print statement is executed.i.e., "Entered integers are not distinct".
Note: We can only compare three integer values using this program. If you require comparing more values, You can go for array data structure.
Comments
Post a Comment