One for getting input One to compute and return the wind chill One to compute an
ID: 3590500 • Letter: O
Question
One for getting input
One to compute and return the wind chill
One to compute and return the cloud base
One for the output
The output will be formatted exactly as shown below (use setw(x)) with the introduction as shown and notes as appropriate.
Use the cmath library for the power function (i.e. you need #include <cmath>)
The equation for approximating the wind chill factor in North America is:
wc = 35.74 + 0.6215 * Ta - 35.75 * V0.16 + 0.4275 * Ta * V0.16
Where:
Ta is the air temperature in Fahrenheit
V is the wind speed in mph (use the pow(windSpeed,0.16))
Note: it's acceptable to use the different magic numbers within your program
Output screen captures and test data I This program determines wind chill using temperatureI I in Fahrenheit and wind speed in mph, and computes I the cloud base using the dew point in Fahrenheit Enter the temperature in degroos Fahrenheit: 20 Enter the wind speed in mph: 15 Enter the deu point in degrees Fahrenheit: 5 Temperature ind Speed Dew Point ind Chill Cloud Base 20.0 dF 15.0 mph 5.0 dF 6.2 dF 3409.1 ft Output screen captures and test data I This program deternines wind chill using temperature I I in Fahrenheit and wind speed in nph, and computes I the cloud base using the dew point in Fahrenheit Enter the temperature in degrees Fahrenheit: 46 Enter the wind speed in ph Enter the dew point in degrees Fahrenheit: 37 Tenperature Wind Speed Dew Point Wind Chill Cloud Base 46.0 dF 7.0 mph 37.0 dF 42.4 dF 2045.5 ftExplanation / Answer
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
void takeInput(float *temp, float *wp, float *dp){
printf(" Enter the temprature in degrees Fahrenheit: ");
scanf("%f",temp);
printf("%.1f ",*temp);
printf(" Enter the wind speed in mph: ");
scanf("%f",wp);
printf("%.1f ",*wp);
printf(" Enter the dew point in degrees Fahrenheit: ");
scanf("%f",dp);
printf("%.1f ",*dp);
}
float calculateWC(float &temp,float &wp){
return 35.74 + 0.6215*temp - 35.75*pow(wp,0.16) + 0.4275*temp*pow(wp,0.16);
}
float calculateCB(float &temp,float &dp){
return (temp-dp)*1000/4.4;
}
void showOutput(float temp,float wp,float dp,float wc,float cb){
std::cout << std::fixed;
std::cout << std::setprecision(1);
cout<<endl;
cout<<setw(15);
cout<<"Temprature";
cout<<setw(15);
cout<<"Wind Speed";
cout<<setw(15);
cout<<"Dew Point";
cout<<setw(15);
cout<<"Wind Chill";
cout<<setw(15);
cout<<"Cloud Base";
cout<<endl<<" ";
for(int i=0;i<75;i++){
cout<<"-";
}
cout<<endl;
cout<<setw(11);
cout<<temp<<" df";
cout<<setw(11);
cout<<wp<<" mph";
cout<<setw(11);
cout<<dp<<" df";
cout<<setw(11);
if(wc>=50||wp<=3)
cout<<"***";
else
cout<<wc<<" df";
cout<<setw(11);
cout<<cb<<" ft";
cout<<endl<<" ";
if(wc>=50||wp<=3){
cout<<" *** Temprature must be 50 degrees or less, and windspeed must be above 3 mph to calculate the wind chill";
}
}
int main() {
printf(" --------------------------------------------------------- | This program determines wind chill using temprature | | in Farhenheit and wind speed in mph. and computes | | the cloud base using the dew point in Fahrenheit | --------------------------------------------------------- ");
printf(" ");
float temp,wp,dp,wc,cb;
takeInput(&temp,&wp,&dp);
wc = calculateWC(temp,wp);
cb = calculateCB(temp,dp);
showOutput(temp,wp,dp,wc,cb);
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.