write a java program to find cube root of a number.
Answers
Answer:
Live Demo
package com.tutorialspoint;
import java.lang.*;
public class MathDemo {
public static void main(String[] args) {
// get two double numbers
double x = 125;
double y = 10;
// print the cube roots of three numbers
System.out.println("Math.cbrt(" + x + ")=" + Math.cbrt(x));
System.out.println("Math.cbrt(" + y + ")=" + Math.cbrt(y));
System.out.println("Math.cbrt(-27)=" + Math.cbrt(-27));
}
}
Explanation:
Answer:
import java.util.Scanner;
public class Root
{
void compute( )
{
Scanner sc=new Scanner(System.in) ;
int num;
System.out.print("Enter integer number:");
num=sc.nextInt( );
System.out.println("Cube Root of" + num + "is:" + Math.cbrt(num)) ;
}
}
Explanation:
The Math.cbrt methods returns the cube root of a number given as its arguments.