I am interested to see how an expert would approach a simple scenario such as this:

4. Write a Java program which finds the square root of a positive double number recursively using the following algorithm:

A) input the number, x

B) if the number entered for x is positive: continue. If the number entered for x is negative or zero in value reject the number, display an error message and return to step A.

C) compute the first estimate of the square root of x by dividing x by 2.

D) 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.

E) continue to calculate new values for the estimate of the square root until the absolute value of (ne – pe) < 0.0001.

F) display the original number x and the estimated square root of x.

Thank you.

Open in new window

As you can see it's very similar to PHP. At some point you start to realize that all languages are really the same - you just need to know how to map from your mental model to the one you happen to be writing in at the moment :)

Doug