Monday, July 16, 2018

How do you calculate Cube Root of a number in Java?

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

No comments:

Post a Comment

How to run standalone mock server on local laptop

 Please download the standalone wiremock server from Direct download section at the bottom of the page.  Download and installation Feel fre...