import java.util.*;
class largest
{
public static void main(String args[])
{
Scanner sc= new Scanner(System.in);
int a,b,c;
System.out.println("Enter the 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
System.out.println("The largest number is"+c);
}
}
Output:
Enter the three numbers
10
20
30
The largest number is 30
import java.util.*;
class smallest
{
public static void main(String args[])
{
Scanner sc= new Scanner(System.in);
int a,b,c;
System.out.println("Enter the two number");
a=sc.nextInt();
b=sc.nextInt();
c=sc.nextInt();
if(a<b && a<c)
System.out.println("The smallest number is"+a);
else if(b<a && b<c)
System.out.println("The smallest number is"+b);
else
System.out.println("The smallest number is"+c);
}
}
Output:
Enter the three numbers
10
20
30
The smallest number is 10
class largest
{
public static void main(String args[])
{
Scanner sc= new Scanner(System.in);
int a,b,c;
System.out.println("Enter the 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
System.out.println("The largest number is"+c);
}
}
Output:
Enter the three numbers
10
20
30
The largest number is 30
import java.util.*;
class smallest
{
public static void main(String args[])
{
Scanner sc= new Scanner(System.in);
int a,b,c;
System.out.println("Enter the two number");
a=sc.nextInt();
b=sc.nextInt();
c=sc.nextInt();
if(a<b && a<c)
System.out.println("The smallest number is"+a);
else if(b<a && b<c)
System.out.println("The smallest number is"+b);
else
System.out.println("The smallest number is"+c);
}
}
Output:
Enter the three numbers
10
20
30
The smallest number is 10