Search the web
Custom Search


Program Based On Inbuilt Function

WAP to accept two numbers find the largest and print its square root. And print the square of the smaller one.

Program:

import java.io.*;
public class inbuilt2
{
public static void main(String args[])throws IOException
{
InputStreamReader read = new InputStreamReader(System.in);
BufferedReader in = new BufferedReader(read);
double square=0;

System.out.println("Enter the first number");
int one=Integer.parseInt(in.readLine());
System.out.println("Enter the second number");
int two=Integer.parseInt(in.readLine());

int large=Math.max(one,two);
int less = Math.min(one,two);
double squareroot=Math.sqrt(large);
square=Math.pow(less,2);

System.out.println("The square root of the larger number is = "+squareroot);
System.out.println("The square of the smaller number is = "+square);
}
}


Program Execution:

Enter the first number
100
Enter the second number
6
The square root of the larger number is = 10.0
The square of the smaller number is = 36.0
Post a Comment


Search the web
Custom Search


All Rights Reserved