Sunday, December 14, 2008

Gratest number in given three in puts

import java .io.*;
public class Greater
{
public static void main(String args[])throws IOException
{
String s1=null;
String s2=null,s3=null;
int a,b,c;
try
{
BufferedReader b1 = new BufferedReader(new InputStreamReader(System.in));
BufferedReader b2 = new BufferedReader(new InputStreamReader(System.in));
BufferedReader b3 = new BufferedReader(new InputStreamReader(System.in));
System.out.println("enter a value");
s1 = b1.readLine();
a=Integer.parseInt(s1);


System.out.println("enter b value");
s2 = b2.readLine();
b=Integer.parseInt(s2);

System.out.println("enter c value");
s3 = b3.readLine();
c=Integer.parseInt(s3);


}
catch(NumberFormatException nfe)
{
System.out.println("invalid integer:"+nfe);
return;
}
System.out.println("a value is:"+a);
System.out.println("b value is:"+b);
System.out.println("c value is:"+c);

if((a>b) && (a>c))
System.out.println( a+ "is greater" );
else
if((b>a) & (b>c))
System.out.println( b+ "is greater");
else
if((c>a) & (c>b))
System.out.println( c+ "is greater");
if((a System.out.println( a+ "is smaller");
else
if((b System.out.println( b+ "is smaller");
else
if((c System.out.println( c+ "is smaller");


}
}


No comments: