## Program "rockplot" The final program in our sequence on Water Rockets

This is the concluding exercise in the sequence on Water Rockets. In the previous exercise (rockarray) we rewrote our program in terms of time, velocity and height arrays, and wrote three new array methods to do various tasks based on these arrays. In the final program we will replace the method printarrays with a new method 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 velocity and height as functions of elapsed time, rather than just a printout of the respective coordinate arrays.

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

```

enter the filename containing the rocket data: urieli.data
get rocket data from the "urieli.data" file
43, 591, 0.4, 0.3
4, 0.3, 8
################################################
The small urieli root beer water rocket -10/16/06
The above data items are (in sequence):
mass [gm] - solid mass (rocket + payload)
vtotal [cc] - total volume (water + air)
dnoz [cm] - diameter of nozzle
fill - fill ratio (water/total volume)
pgage [atm] - charge gage pressure [atmospheres]
cdrag - Coefficient of drag
dbottle [cm] - outside diameter of bottle
################################################
Water rocket initialized as follows:
Solid mass[gm]: 43, total volume[liters]: 0.591
absolute charge pressure[kPa]: 500
initial air charge volume[liters]: 0.4137
Nozzle free flow area [sq.cm]: 0.125664
Bottle cross sect. area [sq.cm]: 50.2655
Density - water: 1000kg/m^3, outside air: 1.2kg/m^3
Drag coefficient: 0.3
gravity acceleration: 9.807m/s^2
enter the max time to test (sec)
6
value entered is 6(s)
enter the number of points to evaluate
21
number of points is 21
plot width is 61 characters
rocket upward velocity(m/s) vs time(s):
0                            *
0.3                            I             *
0.6                            I                                   *
0.9                            I                          *
1.2                            I                    *
1.5                            I              *
1.8                            I          *
2.1                            I      *
2.4                            I  *
2.7                            *
3                        *   I
3.3                     *      I
3.6                 *          I
3.9               *            I
4.2            *               I
4.5          *                 I
4.8        *                   I
5.1       *                    I
5.4      *                     I
5.7     *                      I
6    *                       I
minimum value: -19.583, maximum value: 29.5986
rocket height attained(m) vs time(s):
0                *
0.3                I *
0.6                I          *
0.9                I                     *
1.2                I                              *
1.5                I                                     *
1.8                I                                          *
2.1                I                                             *
2.4                I                                               *
2.7                I                                               *
3                I                                              *
3.3                I                                            *
3.6                I                                         *
3.9                I                                     *
4.2                I                               *
4.5                I                          *
4.8                I                   *
5.1                I           *
5.4                I    *
5.7            *   I
6    *           I
minimum value: -8.02138, maximum value: 32.7064
enter the filename: urieli.out
21 rows of data written to "urieli.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:

• A function plotarrays (in class Plot) is invoked to sequentially do the text charater plot of velocity and height vs time as well as determine and display the respective minimum and maximum values for each plot.
• Notice from the output above that both functions getrocket and savearrays have been modified to allow the user to choose the file name from the keyboard. Notice below how this is done for method savearrays. Furthermore, for purposes of grading you will need to copy the file nielsen.data from the programs directory to your home directory.
 ` char filename[15];` ``` cout << "enter filename to save data\n"; cin >> filename; cout << "opening file \"" << filename << "\"\n"; ofstream outfile(filename); assert(outfile);```

The source code should be in your home directory and named rockplot.cpp, together with the relevant header files rockplot.h and plot.h which you developed in lab, by 10:00 am of the due date.

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:

```nielsen.data
6.0
-5      {what in the Galaxies is this number doing here?}
21
nielsen.out```