The Stimsonian Institute has been flooded with complaints about the number of fatalities caused by their elevator. In order to prove the safety of the elevator, they have asked you to write a simulation of the elevator to mathematically demonstrate its unquestionable safety.
An elevator can be modeled as the following object:
class Elevator
{
public:
Elevator();
Elevator(int numFloors, double floorHeight);
int getCurrFloor() const;
int getFloors() const;
double getFloorHeight() const;
void setFloors(int numFloors);
void setFloorHeight(double floorHeight);
private:
int m_currFloor;
int m_floors;
double m_height;
};
Write a program that implements the Elevator and a driver that tests the Elevator. Make sure that both m_floors and m_height are greater than or equal to 0 in both the mutator functions and constructors. Set all private variables to 0 in your default constructor. Also, set the m_currFloor to 0 in your constructor.
Extent Part I to add a member function to run the elevator from the current floor to the destination floor. Make sure the destination floor actually exists (i.e., it is not negative or above the roof level). Have the function return how long it took to ride, which can be modeled using this equation:
![]()
for current floor c, destination floor d, and floor height h.
In Lab 04, we explored the elevator falling using air drag. The previous air drag equations assumed dry air at 20° C with a fixed cross sectional area of the elevator. Dr. Chris Roush, the Senior Elevator Safety Expert from the Steven Dodd Foundation for Unsafe Vehicle Travel, noted that the central heating system at the Institute is highly unreliable so all types of atmospheric conditions must be simulated. For your reference, here is a list of parameters Dr. Roush provided to write your simulation:
| Variable | Meaning | Range |
| T | Temperature (K) | [183, 331] |
| p | Pressure (Pa) | [87000, 108380] |
| C | Air Drag Constant | (0, 2.5] |
| A | Cross Sectional Area (m2) | (0, ∞) |
| φ | Relative Humidity | [0, 1] |
| ρ | Density (kg / m2) | (calculated) |
| pd | Dry Pressure (Pa) | (calculated) |
| ps | Saturation Pressure (Pa) | (calculated) |
| pv | Wet Pressure (Pa) | (calculated) |
What we first need is ps, pv, and pd:

Now we can find the density of the air:
![]()
Now we can fall based on the equations from Lab 04:

Extend your Part II to implement this algorithm in a member function called fall(). Have this function pass in all required parameters and return the number of seconds it took the elevator to fall as a double. Remember to let a0 = v0 = x0 = 0.
![[Dilbert]](dilbert.gif)