Question: JAVA 3 Recursion; The following algorithm finds the square root of a positive number: Algorithm squareRoot(number, lowGuess, highGuess, tolerance) newGuess = (lowGuess + highGuess) /
JAVA 3 Recursion;
The following algorithm finds the square root of a positive number:
Algorithm squareRoot(number, lowGuess, highGuess, tolerance)
newGuess = (lowGuess + highGuess) / 2
if ((highGuess - newGuess) / newGuess < tolerance)
return newGuess
else if (newGuess * newGuess > number)
return squareRoot(number, lowGuess, newGuess, tolerance)
else if (newGuess * newGuess < number)
return squareRoot(number, newGuess, highGuess, tolerance)
else
return newGuess
To begin the computation, you need a value lowGuess less than the square root of the number and a value highGuess that is larger. You can use zero as lowGuess and the number itself as highGuess . The param-eter tolerance controls the precision of the result independently of the magnitude of number . For example, computing the square root of 250 with tolerance equal to 0.00005 results in 15.81. This result has four digits of accuracy.
Implement this algorithm.
Implement and exercise the algorithm to verify its functionality. Be sure to test with multiple values to insure its correct implementation.
Requirements: You will submit the following with this lab:
b. Create a folder using your last name as the name of the folder
c. Develop the stack class and test class in that folder
d. When completed, zip the contents, and
e. Submit the lab through the Canvas (online sections) or Dropbox (F2F sections) methanisms.
*Need answers ASAP please!
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
