1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
|
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
//functions
void input_data(double &fahrenhiet, double &windspeed, double &dewPoint);
double wind_chill(double fahrenheit, double windSpeed);
double cloud_base(double fahrenheit, double windSpeed);
void output_data(double fahrenheit, double windSpeed, double dewPoint, double wc, double cb);
int main()
{ //Variables
double fahrenheit, windSpeed, dewPoint, wc, cb;
//Calling functions
input_data(fahrenheit, windSpeed, dewPoint);
wc = wind_chill(fahrenheit, windSpeed);
cb = cloud_base(fahrenheit, dewPoint);
output_data(fahrenheit, windSpeed, dewPoint, wc, cb);
return 0;
}
// input_data function
void input_data(double &fahrenheit, double &windSpeed, double &dewPoint)
{ //formatting input
cout << " -----------------------------------------------------------" << endl;
cout << "|" << setw(60) << "|" << endl;
cout << "|" << " This program determines wind chill using temperature " << "|" << endl;
cout << "|" << " in Farenheit and win speed in mph, and computes " << setw(5) << "|" << endl;
cout << "|" << " the cloud base using the dew point in Farenheit. " << "|" <<endl;
cout << "|" << setw(60) << "|" << endl;
cout << " -----------------------------------------------------------" << endl;
cout << "\nEnter the temperature in degrees Farenheit: ";
cin >> fahrenheit;
cout << "Enter the wind speed in mph: ";
cin >> windSpeed;
cout << "Enter the dew point in degrees Fahrenheit: ";
cin >> dewPoint;
}
//function calculating wind chill
double wind_chill(double fahrenheit, double windSpeed)
{
double wc = 35.74+.6215*(fahrenheit)-35.75*(pow(windSpeed,0.16))+0.4275*(fahrenheit)*(pow(windSpeed,0.16));
return wc;
}
//functino calculating cloud base
double cloud_base(double fahrenheit, double dewPoint)
{
double tempSpread = fahrenheit - dewPoint;
double cb = (tempSpread/4.4)*1000;
return cb;
}
//output function to display data
void output_data(double fahrenheit, double windSpeed, double dewPoint, double wc, double cb)
{
cout << fixed << setprecision(1);
//formatting output
cout << "\nTemperature " << "Wind speed" << " Dew Point" << " Wind Chill" << " Cloud Base";
cout << "\n--------------------------------------------------------------------" << endl;
cout << setw(7) <<fahrenheit << setw(15) << windSpeed << setw(14) << dewPoint << setw(14) << wc << setw(15) << cb;
}
|