Create a program that will accept two functions and display the greater number.The program must use appropriate Math class function to find the greater value.

import java.io.*;
public class Max
{
    public static void main(String args[])throws IOException
	{ 
	   float num1;
	   float num2;
	   double max;
	   InputStreamReader obj=new InputStreamReader(System.in);
	   BufferedReader objectBR=new BufferedReader(obj);
	   System.out.printIn("Enter the first number");
	   String n1=objectBR.readLine();
	   num1=Integer.parselnt(n1);
	   System.out.printIn("Enter second number");
	   String n2=objectBR.readLine();
	   num2=Integer.parselnt(n2);
	   max=Math.max(num1,num2);
	   System.out.printIn('\f');
	   System.out.printIn("First number is:"+num1);
	   System.out.printIn("Second number is:"+num2);
	   System.out.printIn("Greater number is:"+max);
	}
}

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Posts

Show Buttons
Hide Buttons