Hot Air Balloons - 3 (Program: "balloop")

In the first program of the sequence (balloon), every time you wanted to evaluate a (altitude, payload) coordinate point you had to invoke the program. It would be much more convenient to obtain a sequence of (altitude, payload) points over an entire range of values. This can be done using a loop. In this exercise we will extend the previous program (balroot) to first evaluate a sequence of coordinate points and then evaluate the root. There are two modifications to be done to the main function module only, as follows:

1. You will need to separate your program into two files, the program file balloop.cpp and the header file balloop.h. In order to see how this is done, we have taken our pendulum case study example gfun.cpp from the week3 directory, and separated it into a program file gfun1.cpp and a header file gfun1.h.

2. In this exercise the program will invoke the Balloon class method find_payload over a range of values in a loop. It is important that the for loop be located in the main function module, and not in the function find_payload. To obtain a sequence of (altitude, payload) points we will need to enter the low and high values of altitude required, as well as the number of data points to be evaluated over the range. For each data point in the loop a new altitude is evaluated and the relevant value of payload is determined by invoking function find_payload. The paradigm for this exercise is the program sin.cpp in the week6 directory, in which we display two columns of n coordinate points using a for loop. Subsequently the altitude attained using a specific payload is evaluated, as in the previous exercise.

Thus a typical execution of the program will lead to the following output:

 enter balloon volume (typically 1000 cu.m):
1000
 enter balloon empty mass (typ. 100)[kg]
100
balloon initialised as follows:
 balloon volume: 1000[cu.m]
 balloon empty mass: 100[kg]
standard atmospheric conditions:
 temperature lapse rate: -0.0065[deg C/m]
 temperature at sea level: 15[deg C]
 standard pressure at sea level: 101325[Pa]
determine a sequence of (altitude,payload) points
enter low and high bounds of altitude [m]:
0 13000
altitude bounds are [0.0,13000.0] [m]
enter the number of points to evaluate
14
number of points entered is 14
   altitude[m]   payload[kg]
       0.0          179.4
    1000.0          172.9
    2000.0          164.6
    3000.0          154.8
    4000.0          143.9
    5000.0          132.0
    6000.0          119.4
    7000.0          106.3
    8000.0           92.9
    9000.0           79.4
   10000.0           65.9
   11000.0           52.6
WARNING! Altitude 12000.0[m] out of range
   12000.0            0.0
WARNING! Altitude 13000.0[m] out of range
   13000.0            0.0
find altitude as a function of required payload
enter the required payload [kg]:
150
required payload entered is 150.0[kg]
enter required accuracy in altitude [m]
1
required accuracy is 1.0[m]
WARNING! Altitude 13000.0[m] out of range
for a required payload of 150.0[kg]
altitude attained is 3451.1[m]

Notice the various items of data entry to this program are written in Italics script. The sequence with which data is entered is important, since your programs are tested with an input data file. The following is a typical data sequence (used in the example above). Be sure that your program will operate with the data as shown:

1000
100
0
13000
14
150
1

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