Weather Balloons A.A Weather balloons are used to gather temperature and pressur
ID: 3640529 • Letter: W
Question
Weather Balloons A.AWeather 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 denser, 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.
Output a file with a table of altitude and 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.
Also output the peak altitude and its corresponding time.
Implementation:
Validate all input.
Output File = output.txt
RUN sample:
Enter initial value for table (in hours) => 0
Enter increment between lines (in hours) => 1
Enter final value for table (in hours) => 5
Explanation / Answer
please rate - thanks
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cmath>
using namespace std;
int main()
{ofstream out;
int start,stop,incr,peakt,i;
double peak=-1000,vel,alt,t;
out.open("output.txt");
out<<"altitute velocity meters meters/sec ";
cout<<"Enter initial value for table (in hours) => ";
cin>>start;
while(start>=48)
{cout<<"must be <48 ";
cout<<"Enter initial value for table (in hours) => ";
cin>>start;
}
cout<<"Enter increment between lines (in hours) => ";
cin>>incr;
while(incr>=48)
{cout<<"must be <48 ";
cout<<"Enter increment between lines (in hours) => ";
cin>>incr;
}
cout<<"Enter final value for table (in hours) => ";
cin>>stop;
while(stop>=48&&stop<=start)
{cout<<"must be <48 and >start time ";
cout<<"Enter final value for table (in hours) => ";
cin>>stop;
}
for(i=start;i<=stop;i+=incr)
{t=(double)i;
alt=-0.12*pow(t,4) + 12*pow(t,3) - 380*pow(t,2)+ 4100*t + 220;
vel=-.48*pow(t,3)+36*pow(t,2)-760*t+4100;
vel=vel/(60*60);
out<<alt<<" "<<vel<<endl;
if(alt>peak)
{peak=alt;
peakt=i;
}
}
out<<"peak altitute: "<<peak<<endl;
out<<"at time: "<<peakt<<endl;
out.close();
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.