WAP to find maximum and minimum number from three numbers.
import java.io.DataInputStream;
class MinMax
{
public static void main(String args[])
{
int a,b,c;
System.out.println("Enter the three number:");
System.out.println("------------------------");
try
{
DataInputStream obj=new DataInputStream(System.in);
System.out.print("a=");
a=Integer.parseInt(obj.readLine());
System.out.print("b=");
b=Integer.parseInt(obj.readLine());
System.out.print("c=");
c=Integer.parseInt(obj.readLine());
System.out.println("-------------");
if(a>b && a>c)
{
System.out.println("a is Max=" +a);
if(b<c)
{
System.out.println("b is Min=" +b);
}
else
{
System.out.println("c is Min=" +c);
}
}
else if(b>c && b>a)
{
{
System.out.println("b is Max=" +b);
if(a<c)
{
System.out.println("a is Min=" +a);
}
else
{
System.out.println("c is Min=" +c);
}
}
}
else
{
System.out.println("c is Max=" +c);
if(a<b)
{
System.out.println("a is Min=" +a);
}
else
{
System.out.println("b is Min=" +b);
}
}
}
catch(Exception e)
{
System.out.println("in velid" +e);
}
}
}
0 comments:
Post a Comment