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

Getting errors with the previous answer, so I am trying again. Thanks for the he

ID: 3641264 • Letter: G

Question

Getting errors with the previous answer, so I am trying again. Thanks for the help!

Here is my problem: Write a java program which finds the square root of a positive double number recursively using the following algorithm:
1. (This part I am good) input a positive number for x, throw an exception if negative number is entered
2. compute the first esitmate of the square root of x by dividing x by 2
3. compute the next estimate of the square root of x (call the next estimate ne) from the previous estimate of the square root of x (call the previous estimate pe_ by using the formula: ne = (pe + x / pe) /2
4. Continue to calculate new values for the estimate of the square root until the absolute value of (ne-pe) < 0.0001
5. display the original number of x and the estimated square root of x

Explanation / Answer

public static double SQRT(double x) { double pe; double ne = x / 2; do { pe = ne; ne = (pe + x / pe) / 2; } while (pe - ne > .0001 || ne - pe > .0001); System.out.println(x + " " + ne); return ne; } public static void main(String[] args) { SQRT(10); } This code is working well (its just the SQRT function copy it into your code, also you have got the throw part so i have not written it)

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote