Follow on Facebook

Like and Share on Facebook

Tuesday, March 10, 2015

Write a program to Find Largest Number Among Three in java using BufferedReader

import java.io.*;
class largest
{

 public static void main(String args[])throws IOException
 {
  int a,b,c,large;
 
            BufferedReader br=new BufferedReader( new InputStreamReader(System.in));
            System.out.println("Enter 3 numbers");
            a=Integer.parseInt(br.readLine());
            b=Integer.parseInt(br.readLine());
            c=Integer.parseInt(br.readLine());
            if(a>b & a>c)
            {
         
       large=a;
            }
    else if(b>c)
    {
 
       large=b;
    }
    else
    {
 
       large=c;
    }
   System.out.println("The largest number is "+large);
 }

}

Output:

Enter 3 numbers
56
45
12
The largest number is 56

No comments:

Post a Comment