Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The following method was known to the ancient Greeks for computing square roots.

ID: 3683712 • Letter: T

Question

The following method was known to the ancient Greeks for computing square roots. Given a value x > 0, and a guess g for the square root, a better guess is (g + x/g)/2. Write a recursive helper method public static squareRootGuess(double x, double g). If g2 is approximately equal to x (that is, less than .0001 difference between x and g), return g, otherwise, return squareRootGuess with the better guess. Then write a method public static squareRoot(double x) that uses the helper method.

You do not need a screen-shot of this lab.

Here is a sample run from a working project:

Enter a number: 27

The square root is of 27.000 is 5.19615

Expected value: 5.19615

Explanation / Answer

import java.util.Scanner public class SquareRoot { public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.println(“please enter a number to find its square root”); double x = in.nextDouble(); System.out.println(“ The square root is” + squareRoot(x)); } public static double squareRoot(double x) { return squareRootGuess(double x,double g) } {final double value= .0001; if(Math.abs(x-g*g)