write a java program to calculate the cube root,square root,power.
Answers
Answer:
sqrt(double s) method of Math class can be used to find the square root of the double or int value. cbrt(double c) method of Math class can be used to find the cube root of the double or int value. Both the methods are static, so it can be called directly using class name without creating object.
hey A.R.M.Y
Answer:
Hey there !
Here is the answer...
Explanation:
For cube root -
import java.util.Scanner;
double num;
Scanner sc = new Scanner (System.in);
System.out.println ("Enter a number...");
num = sc.nextDouble ();
doubke cbrt = Math.pow (num, 1/3);
System.out.println ("Cbrt of number u entered is" + cbrt);
For square root -
import java.util.Scanner;
double num;
Scanner sc = new Scanner (System.in);
System.out.println ("Enter a number...");
num = sc.nextDouble ();
double sqrt = Math.pow (num, 1/2);
System.out.println ("sqrt of number u entered is" + sqrt);
For computing any number to a certain power -
import java.util.Scanner;
double num1, num2;
Scanner sc1 = new Scanner (System.in);
Scanner sc2 = new Scanner (System.in);
System.out.println ("Enter a number 1...");
num1 = sc1.nextDouble ();
System.out.println ("Enter a number 2...");
num2 = sc2.nextDouble ();
double calc = Math.pow (num1, num2);
System.out.println ("num1 ^ num2 of =" + calc);