Be sure you have read chapter 8.
Do the following programming problems. You will end up with at least one code file per problem. Submit your program source (and any other needed files) by sending mail to bmassing@cs.trinity.edu, with each file as an attachment. Please use a subject line that mentions the course and the assignment (e.g., ``csci 1320 homework 5'' or ``CS1 hw5''). You can develop your programs on any system that provides the needed functionality, but I will test them on one of the department's Linux machines, so you should probably make sure they work in that environment before turning them in.
 starts
with an initial guess
 starts
with an initial guess  and then repeatedly refines it using
the formula
 and then repeatedly refines it using
the formula 
 
Repetition continues until the absolute value of
 -
 -  is less than some specified threshold value.
An easy if not necessarily optimal initial guess is just
 is less than some specified threshold value.
An easy if not necessarily optimal initial guess is just  .
.
Write a Scala program that implements this algorithm and compares
its results to those obtained with the library function 
math.sqrt().  
Have the program prompt for  , the threshold value,
and a maximum number of iterations; 
do the above-described computation; 
and print the result, the actual number of iterations, 
and the square root of
, the threshold value,
and a maximum number of iterations; 
do the above-described computation; 
and print the result, the actual number of iterations, 
and the square root of  as computed using library function sqrt().
Also have the program print an error message if the input is negative.
Here is a sample execution 
(with text in boldface what you type
and text in typewriter font what the program prints):
 as computed using library function sqrt().
Also have the program print an error message if the input is negative.
Here is a sample execution 
(with text in boldface what you type
and text in typewriter font what the program prints):
enter number to find the square root of:
2
enter threshold:
.00000001
enter maximum number of iterations:
100
result with Newton's method = 1.4142135623746899 (4 iterations)
result from library function = 1.4142135623730951