Problem statement: Find the cube root of a number in java.
public class CubeRootExe {
public static void main(String args[]) {
double cbRt = cubeRoot(8);
System.out.println(cbRt);
}
public static double cubeRoot(double n) {
return Math.cbrt(n);
}
}
Output:
2.0
public class CubeRootExe {
public static void main(String args[]) {
double cbRt = cubeRoot(8);
System.out.println(cbRt);
}
public static double cubeRoot(double n) {
return Math.cbrt(n);
}
}
Output:
2.0
No comments:
Post a Comment