Down below is my c++ program so far : #include<iostream> using namespace std; do
ID: 3751633 • Letter: D
Question
Down below is my c++ program so far :
#include<iostream>
using namespace std; double x, y, z, a, b, windchillcalculation, heatindexcalculation;
int main() { int choice; cout<<" choose one of the following choice and type 1 or 2"<<endl; cout<<" 1 wind chill"<<endl; cout<<" 2 heat index"<<endl; cin>>choice; if(choice==1) { cout<<" enter the temperature in degrees Celsius "; cin>>z; cout<<endl; cout<<" enter the wind speed in m/s"; cin>>x; cout<<endl; cout<<" enter the relative humidity(%) :"; cin>>y; cout<<endl; windchillcalculation=() } if(choice==2) { cout<<"enter the temperature in degrees Celsius :"; cin>>a; cout<<endl; cout<<"User please enter the relative humidity(%) :"; cin>>b; cout<<endl; } } #include<iostream>
using namespace std; double x, y, z, a, b, windchillcalculation, heatindexcalculation;
int main() { int choice; cout<<" choose one of the following choice and type 1 or 2"<<endl; cout<<" 1 wind chill"<<endl; cout<<" 2 heat index"<<endl; cin>>choice; if(choice==1) { cout<<" enter the temperature in degrees Celsius "; cin>>z; cout<<endl; cout<<" enter the wind speed in m/s"; cin>>x; cout<<endl; cout<<" enter the relative humidity(%) :"; cin>>y; cout<<endl; windchillcalculation=() } cout<<endl; cout<<" enter the wind speed in m/s"; cin>>x; cout<<endl; cout<<" enter the relative humidity(%) :"; cin>>y; cout<<endl; windchillcalculation=() } if(choice==2) { cout<<"enter the temperature in degrees Celsius :"; cin>>a; cout<<endl; cout<<"User please enter the relative humidity(%) :"; cin>>b; cout<<endl; } } if(choice==2) { cout<<"enter the temperature in degrees Celsius :"; cin>>a; cout<<endl; cout<<"User please enter the relative humidity(%) :"; cin>>b; cout<<endl; } } The temperature perceived by the human body is a function of ambient air temperature and other factors, including wind speed, humidity, and solar radiation. Perceived temperature can be modeled using simplified formulas as either heat index or wind chill. Create a program to calculate either the heat index or the wind chill, based on the user's choice. Ask the user to make a selection: 1. wind chill (up to 20 degrees Celsius) heat index (20 degrees Celsius and above) 2. For wind chill, prompt the user for: temperature in degrees Celsius wind speed in m/s (at 10m elevation) relative humidity (%) . Formula for wind chill (apparent temperature): AT Ta +0.33xe -0.70xws-4.00 where Ta dry bulb air temperature in degrees Celsius ws wind speed at 10m of elevation e = water vapor pressure, according to the following formula: e- rh/100x 6.105x exp (17.27 x Ta/(237.7+ Ta)) where rhs relative humidity (%) For heat index, prompt the user for: temperature in degrees Celsius relative humidity (%) . Calculate heat index (WBGT) using this formula: WBGT-(0.567 x Ta)+ (0.393 x e)+3.94 where Ta - dry bulb air temperature in degrees Celsius e water vapor pressure, according to the following formula: e (rh/100) x6.105 x exp (17.27 x Ta/(237.7 +Ta )) Celsius to the nearest whole degree. Be sure to use the Report the result in degrees appropriate data types for the variables and constants in your program. Take care to compose user interface that will give the user a comfortable experience.
Explanation / Answer
C++:
#include<iostream>
#include <math.h>
using namespace std;
double ws,rh,temp,answer;
double func()
{
return rh/100*6.105*exp(17.27*temp/(237.7+temp));
}
void windchillcalculation()
{
answer=temp+0.33*func()-0.70*ws-4;
cout<<"Wind Chill: "<<answer<<endl;
}
void heatindexcalculation()
{
answer=0.567*temp+0.393*func()+3.94;
cout<<"Heat Index: "<<answer<<endl;
}
int main()
{
int choice;
cout<<" choose one of the following choice and type 1 or 2"<<endl;
cout<<" 1 wind chill"<<endl;
cout<<" 2 heat index"<<endl;
cin>>choice;
if(choice==1)
{
cout<<" enter the temperature in degrees Celsius ";
cin>>temp;
cout<<" enter the wind speed in m/s";
cin>>ws;
cout<<" enter the relative humidity(%) :";
cin>>rh;
windchillcalculation();
}
else if(choice==2)
{
cout<<"enter the temperature in degrees Celsius :";
cin>>temp;
cout<<"User please enter the relative humidity(%) :";
cin>>rh;
heatindexcalculation();
}
else
cout<<"You entered wrong choice!"<<endl;
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.