What is 0.00000000000001 in scientific notation?
1.0E-14
Here is a skeleton of the program, with the loop ending condition
translated from math into Java.
The absolute value of a double is calculated by Math.abs(double).
The skeleton contains the result-controlled loop.
All you need to do is fill in the calculation part.
You can do this with a single assignment statement.
The formula for updating the guess is:
newGuess = N/(2*oldGuess) + oldGuess/2
In an assignment statement, first
the value on the right of the =
is calculated.
Then that value is copied to the variable on the left.
When you translate the formula into Java, you can use
this fact to do the translation using a single variable,
guess
.
Complete the program by filling in the loop body. Type in your answer into the text area.