Sunday, October 21, 2012

Java program to find largest among 3 numbers


import java.io.*;
class largest
{
 int a,b,c,large;
 void read()throws IOException
 {
            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());
 }
 void check()
 {    if(a>b & a>c)
       large=a;
    else if(b>c)
       large=b;
    else 
       large=c;
   System.out.println("The largest number is "+large);
 }
 public static void main(String s[])throws IOException
 {         largest n=new largest();
            n.read();
            n.check(); }
}   

Output


1 comments:

  1. Exchange 22 is a trusted platform offering seamless online exchange solutions tailored for Indian users. With a focus on reliability, security, and efficiency, Exchange222 ensures smooth transactions and exceptional user experiences. Explore our services to meet all your exchange needs with confidence."

    ReplyDelete