Follow on Facebook

Like and Share on Facebook

Tuesday, February 10, 2015

Write a Program to Find Max Number B/W Two Numbers in Java Using Buffered Reader


import java.io.*;
import java.lang.Math;

class max
{
public static void main (String args[]) throws IOException
{
int a, e;
float b, f;
long c, g;
double d, h;


InputStreamReader ir=new InputStreamReader(System.in);

BufferedReader br =new BufferedReader(ir);

System.out.println("Please Enter the A Integer Value");

a=Integer.parseInt(br.readLine());

System.out.println("Please Enter the A Integer Value");

e=Integer.parseInt(br.readLine());

System.out.println("Please Enter the A Float Value");

b=Float.parseFloat(br.readLine());

System.out.println("Please Enter the A Float Value");

f=Float.parseFloat(br.readLine());


System.out.println("Please Enter the A Long Value");

c=Long.parseLong(br.readLine());

System.out.println("Please Enter the A Long Value");

g=Long.parseLong(br.readLine());


System.out.println("Please Enter the A Double Value");

d=Double.parseDouble(br.readLine());



System.out.println("Please Enter the A Double Value");

h=Double.parseDouble(br.readLine());

System.out.println(" Max Value b/w two Integer Numbers =" +Math.max(a,e));

System.out.println(" Max Value b/w two Float Numbers=" +Math.max(b,f));

System.out.println(" Max Value b/w two Long Numbers =" +Math.max(c,g));

System.out.println(" Max Value b/w two Double Numbers =" +Math.max(d,h));

}
}

--------------------Output--------------------

Please Enter the A Integer Value
34
Please Enter the A Integer Value
56
Please Enter the A Float Value
56.90
Please Enter the A Float Value
56.80
Please Enter the A Long Value
56444
Please Enter the A Long Value
56442
Please Enter the A Double Value
456.90888
Please Enter the A Double Value
456.9087
 Max Value b/w two Integer Numbers =56
 Max Value b/w two Float Numbers=56.9
 Max Value b/w two Long Numbers =56444
 Max Value b/w two Double Numbers =456.90888


Process completed.

No comments:

Post a Comment