Space Shuttle - 5 (Program "shutarray")

This week we learn about arrays (Chapter 10) which will completely change our approach to programming. Our program is a rewrite of the previous program (shutfile) which should be modified in structure to include arrays.

In the main function we declare three arrays having a maximum size of 100 values each - for the time values (time), for the upward velocity values (vel) and for the height values (height). The main function should then invoke three new methods associated with the Shuttle class to do the following tasks:

A new function minmax is invoked to determine the respective minimum and maximum values in the vel and height arrays, which are then displayed on the screen.

All this is shown in the flow diagram below:

Consider the output of a typical execution of program shutarray. Notice that in spite of the significant structural change the program output is almost identical to that of the previous program (shutfile).

 Evaluate upward velocity as function of elapsed time
 get shuttle mass from the "shuttle.mass" file
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
elapsed time(s) velocity(m/s)  height(m)
       0.0           0.0           0.0
      20.0          95.3         917.0
      40.0         214.0        3966.7
      60.0         360.8        9662.6
      80.0         542.1       18628.2
     100.0         766.9       31637.7
     120.0        1047.9       49680.2
     140.0         851.8       68672.9
     160.0         655.7       83752.9
     180.0         459.5       94896.0
     200.0         263.4      102134.7
     220.0          67.2      105426.4
     240.0        -128.9      104825.7
     260.0        -325.0      100275.7
     280.0        -521.2       91813.2
     300.0        -717.3       79441.5
     320.0        -913.5       63102.3
     340.0       -1109.6       42875.0
     360.0       -1305.7       18716.0
     380.0       -1501.9       -9366.9
min velocity: -1501.9(m/s), max velocity: 1047.9(m/s)
min height: -9366.9(m), max height: 105426.4(m)
20 rows of data written to "shuttle.out" file

Both the source code file shutarray.cpp and the header file shutarray.h should be in your home directory by 10:00 am of the due date.

Telnet: "condor"