import java.io.*;
import java.util.*;
public class LargeSmall{
Scanner scan=new Scanner(System.in);
float a, b;
public void input()throws IOException{
System.out.println("Enter any two numbers: ");
a=scan.nextFloat();
b=scan.nextFloat();
}
public void display(){
System.out.println("Large number out of "+a+", "+b+" is: "+(Math.max(a,b)));
System.out.println("Small number out of "+a+", "+b+" is: "+(Math.min(a,b)));
}
public static void main(String[] args)throws IOException{
LargeSmall obj=new LargeSmall();
obj.input();
obj.display();
}
}
In above program "Math.max(a, b)" is use to check which number, a or b, is greater number and "Math.min(a, b)" is use to check which number, a or b, is smaller number.
import java.util.*;
public class LargeSmall{
Scanner scan=new Scanner(System.in);
float a, b;
public void input()throws IOException{
System.out.println("Enter any two numbers: ");
a=scan.nextFloat();
b=scan.nextFloat();
}
public void display(){
System.out.println("Large number out of "+a+", "+b+" is: "+(Math.max(a,b)));
System.out.println("Small number out of "+a+", "+b+" is: "+(Math.min(a,b)));
}
public static void main(String[] args)throws IOException{
LargeSmall obj=new LargeSmall();
obj.input();
obj.display();
}
}
In above program "Math.max(a, b)" is use to check which number, a or b, is greater number and "Math.min(a, b)" is use to check which number, a or b, is smaller number.
Comments