• Calculate the cubic root of a number without using library functions
Detailed Description:
• Interface Description
Prototype:
public static double Getcuberoot (double input)
Input: Double to solve parameter
Return value: Double the cube root of the input parameter
Input Description:
Parameter double type to solve
Output Description:
The cube root of the input parameter is also a double type
Input Example:
216
Output Example:
6.0
1 ImportJava.util.*;2 3 Public classmain{4 Public Static voidMain (string[] args) {5Scanner cin =NewScanner (system.in);6 7 //Two-point search8 while(Cin.hasnext ()) {9 Doubleinput =cin.nextdouble ();Ten DoubleMin = 0; One DoubleMax =input; A DoubleMID = 0; - - //a little more precision to prevent some test cases from failing the while(Max-min > 0.00001) { -Mid = (min + max)/2; - - if(Mid*mid*mid >input) { +Max =mid; -}Else { +Min =mid; A } at } - //output that satisfies the precision, and the same format number output as the C language -System.out.printf ("%.1f\n", min); - } - } -}
Solve cube root