Space Shuttle - 6 (Program "shutplot")

This is the concluding exercise in the sequence on the Space Shuttle. In the previous exercise (shutarray) we rewrote our program in terms of time, velocity and height arrays, and wrote three new array functions to do various tasks based on these arrays. In the final program we will replaced the function printarrays with a new function plotarrays in the new class Plot, as shown in the structure diagram below. This seemingly small change in the somewhat complex structure is significant. It allows us to get a visual appreciation of the nonlinear functions findvel and findheight rather than just a printout of the respective coordinate arrays.

Consider a typical execution of shut_plot as follows (user input is shown in italics):

Evaluate upward velocity as function of elapsed time
 get shuttle mass from file
enter the filename: shuttle.mass
mass read: 2034681.0kg
#####################################
Initial total Shuttle mass in kg
(default value for 20,000kg payload)
#####################################
Shuttle initialized as follows:
 total mass at liftoff: 2034681.0[kg]
 mass of solid fuel at liftoff: 1004250.0[kg]
 booster ejection fuel velocity: 2817.0[m/s],
       mass flow rate: 8369.0[kg/s]
 orbiter ejection fuel velocity: 3636.0[m/s],
       mass flow rate: 1378.0[kg/s]
 initial gravity acceleration: 9.807[m/s^2]
enter elapsed time from liftoff [s]: 
380
value entered is 380.0 seconds
enter the number of points to evaluate
20
number of points is 20
plot width is 61 characters
shuttle velocity vs time:
         0.0                                       *
        20.0                                       I  *
        40.0                                       I    *
        60.0                                       I        *
        80.0                                       I            *
       100.0                                       I                 *
       120.0                                       I                        *
       140.0                                       I                   *
       160.0                                       I               *
       180.0                                       I          *
       200.0                                       I      *
       220.0                                       I *
       240.0                                    *  I
       260.0                                *      I
       280.0                           *           I
       300.0                      *                I
       320.0                  *                    I
       340.0             *                         I
       360.0         *                             I
       380.0    *                                  I
minimum value: -1501.9, maximum value: 1047.9
shuttle height vs time:
         0.0         *
        20.0         *
        40.0         I *
        60.0         I    *
        80.0         I         *
       100.0         I               *
       120.0         I                         *
       140.0         I                                   *
       160.0         I                                           *
       180.0         I                                                *
       200.0         I                                                    *
       220.0         I                                                      *
       240.0         I                                                      *
       260.0         I                                                   *
       280.0         I                                               *
       300.0         I                                        *
       320.0         I                                *
       340.0         I                     *
       360.0         I         *
       380.0    *    I
minimum value: -9366.9, maximum value: 105426.4
enter the filename: shuttle.out
20 rows of data written to "shuttle.out" file

Thus we see that the major difference between this output and that of the previous exercise is the graphical display of the velocity and height versus time data, rather than the three columns of values. This is a significant difference, and allows a quick visualization of the nonlinear functions.

Notice the following:

The source code should be in your home directory and named shutplot.cpp, together with the relevant header file shutplot.h.

Note that the sequence with which data is entered is important, since your programs are tested with a data file. The following is a typical data sequence. Be sure that your program will operate with the data as shown:

shuttle.mass
380.0
-5      {what in the Galaxies is this number doing here?}
20
shuttle.out

Telnet: "condor"