In the previous exercise we managed
to effectively perform the integration of the velocity function
in the *while* loop structure to obtain the cumulative height
attained by the shuttle booster rockets. Unfortunately we find
that the accuracy of our results depends upon the number of points
chosen to evaluate. Consider the following extracts from two typical
executions of program **shutloop**,
in which we evaluate the height attained after an elapsed time
of 120 seconds after lift-off:

Evaluate upward velocity as function of elapsed time for 20,000kg payload, initial total mass is 2,034,681[kg] enter your initial total mass of shuttle [kg]: |

| | | enter elapsed time from liftoff [s]: |

Which is the correct value of height at an elapsed time of 120 s? Is it 62875.9 m? 49713.1 m? Either of them? Clearly we need to evaluate the height independently of the number of points chosen to evaluate.

In this exercise you should extend
the class **Shuttle** of the previous
two exercises to include a new method **find_height**
as indicated in the following structure diagram:

Thus the purpose of method **find_height**
is to integrate the velocity function by means of the Trapezoidal
method in order to evaluate the height attained by the booster
rockets after an elapsed time **etime**,
as indicated in the following diagram:

In order to develop the function you will need to decide on
the number of integration intervals 'n'.
At this stage we have no theoretical means of relating the required
accuracy and the number of intervals. One practical means is to
choose a value for n (say 2) and note
the resulting value of height. Double this value and repeat the
process, then keep doubling n until
the change in the height is within a specified error bound. It
is convenient to use the previous program exercise **shutloop**
for this purpose.

Notice that once we have chosen a value for n then the summation
loop sums the n trapezoidal areas. In our previous exercise we
used the *while* loop structure to do the summation, however
in situations in which we know exactly how many times to execute
the loop, the *for* loop structure is clearer to read. In
this exercise the *for* loop structure should be used.

Finally, professional C++ programs are always separated into at
least two files: the *program* file (often referred to as
the dot-cpp file) and the *header* file (or dot-h file).
In this exercise you will be required to separate your program
into a program file **shutfor.cpp**
and a header file **shutfor.h**.
A direct example is available on **condor**
in the **/home/condor/et181/chapter4**
directory and can been used as a paradigm for thus exercise. Recall
the program **gfun.cpp** to evaluate
the local value of acceleration due to gravity. This program has
been rewritten in terms of **gfun1.cpp**
and **gfun1.h** and can also be
found in the **chapter4** directory.

Extracts of typical execution output for the new program **shutfor** follow:

Evaluate upward velocity as function of elapsed time for 20,000kg payload, initial total mass is 2,034,681[kg] enter your initial total mass of shuttle [kg]: |

| | | enter elapsed time from liftoff [s]: |

Notice that the height evaluated at an elapsed time of 120 seconds is independent of the number of points to evaluate. Apart from that there is no discernable difference in the output.

Both the program file **shutfor.cpp**
and the header file **shutfor.h**
should be located in your home directory by 10:00 a.m. of the
due date.