CSCI 161 lab exercise 6: successive approximation

Lab exercise 6 is to be submitted electronically by 5p.m. Apr. 12th, and covers the work from the lab sessions of Apr. 8-10, suitably cleaned up to adhere to standards. The submission mechanism is detailed below, and must be followed to obtain credit for the lab.

The exercise is worth 5% of your total grade and will be marked out of 10.

Late submissions will be penalized 2.5 marks per day late or portion thereof.


Exercise details:

For this exercise you will be implementing a complete program from scratch, and will have considerably more freedom in the implementation than was the case for labex1-labex5.

The objective is to use a successive approximation technique to calculate the cube root of a positive real number. The basis of the approximation process is the assumption that, if r is the current 'guess' for the cube root of N, then a better (more accurate) guess, rnew, can be obtained using
rnew = ((N/(r2)) + 2r)/3

Your task is this, ask the user to enter an accuracy level, A, between 1 and 2, and ask the user to enter a real number, N.

Your program must pick an initial guess for r, and then repeatedly calculate/replace r with rnew until the following is satisfied:
1/A <= r/rnew <= A

Error checking: be sure your program detects when the user enters invalid values for A and/or N, including cases where they enter text instead of numeric values.


Recommended development sequence

As always, I strongly advise you follow a well-thought out sequence of development steps in completing the exercise, but deciding what they should be is left up to you.


Submission mechanism

All the code for the assignment must be in a single file named labex6.C (correct spelling and capitalization is essential for the submission to work correctly).

To submit the assignment, cd to the directory that contains your labex6.C file and type the following command:

   /home/faculty/wesselsd/bin/submit  161  labex6.C
Note that each submission overwrites any previous submission you have made.


Marking guidelines:

Marks will be based on:

Code standards:

The submission must follow the code standards for labex5