Weather balloons are used to gather temperature and pressure data at various alt
ID: 3629698 • Letter: W
Question
Weather balloons are used to gather temperature and pressure data at various altitudes in the atmosphere. The balloon rises because the density of the helium in the balloon is less than the density of the surrounding air outside the balloon. As the balloon rises, the surrounding air becomes less dense and thus the balloon’s ascent slows until it reaches a point of equilibrium.
During the day, sunlight warms the helium trapped inside the balloon, which causes the helium to expand and become less dense and the balloon to rise higher.
During the night, however, the helium in the balloon cools and becomes more dense, causing the balloon to descend to a lower altitude. The next day, the sun heats the helium again and the balloon rises.
Over time, this process generates a set of altitude measurements that can be approximated with a polynomial equation.
Assume that the polynomial
alt(t) = -0.12t^4 + 12t^3 – 380t^2 + 4100t + 220, where the units of t are hours, represents the altitude or height in meters during the first 48 hours following the launch of a weather balloon.
The corresponding polynomial model for the velocity in meters per hour of the weather balloon is
v(t) = -0.48t^3 + 36t^2 - 760t + 4100
Print a table of the altitude and the velocity for this weather balloon using units of meters and meters per second. Let the user enter the start time, increment in time between lines of the table, and ending time, where all the time values must be less than 48 hours. In addition to printing the table, also print the peak altitude and its corresponding time.
Implementation:
Check to make sure that the final time is greater than the initial. If it is not, ask the user to reenter the complete set of report information.
If there are two times with the same maximum height, program should print the first time that the maximum height occurred.
SAMPLE
Table
Weather Balloon Information
Time(hrs) Height (meters) Velocity (meters/s)
0 220.00 1.14
….
3 9414.28 0.59
Maximum height was ……. and it occurred at ….. hrs
Explanation / Answer
So, you need to calculate the height of the balloon, and the velocity each hour using the equations given. Then you need to print out the data, and store the maximum height values and the time that they occurred. Easy!
You could create a struct with data members height, velocity, and time, but I'm guessing you might not have gone over structs or classes yet, so let's try to keep this whole operation in main. It's pretty easy to splice it up into functions and classes though so if you need to I'll leave that up to you.
I'm not going to use , but if you #include, std::pow(variable, power) is a good way to calculate an exponential. I try to never use name spaces, so I'm not going to use namespace std, but if you need to mess with the code you may wish to add that.
All height and velocity values will be stored in two arrays which can be printed, but they could just be calculated in cout.
#include
#include //for std::setprecision()
int main()
{
int timePeriod = 48; //how long the balloon was up in the air.
int maxTime; //maxTime to hold max time value.
float heightArr[timePeriod], velocityArr[timePeriod];
float maxHeight; //for storing max height
for (int hour = 0; hour < timePeriod; hour++) // calc the values, from 0 to timePeriod.
{
heightArr[hour] = 220 - 0.12*(hour*hour*hour*hour) + 12.0*(hour*hour*hour) - 380*(hour*hour) + 4100.0*hour;
velocityArr[hour] = (-0.48*(hour*hour*hour) + 36*(hour*hour) - 760*hour + 4100);
if (heightArr[hour] > maxHeight)
{
maxHeight = heightArr[hour];
maxTime = hour;
}
}
std::cout << std::setprecision(5); // Only prints out 2 decimals.
std::cout << "time Height Velocity" << std::endl;
std::cout << "(hrs) (meters) (meters/hr) " << std::endl;
for (int hour = 0; hour < timePeriod; hour++) //print the values from 0 to timePeriod
{
std::cout << hour << " " << heightArr[hour] << " " << velocityArr[hour] << std::endl;
}
std::cout << "The max height was " << maxHeight << " and it occurred at " << maxTime << " hrs" << std::endl;
return 0;
}
That aught to do it!
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.