During winter when it is very cold, typically, everyone would like to know the windchill factor, especially, before going out. Meteorologists use the following formula to compute the windchill factor, W:
W = 35.74 + 0.6215 × T - 35.75 × V0.16 + 0.4275 × T × V0.16
where V is the wind speed in miles per hour and T is the temperature in degrees Fahrenheit.
Write a program that prompts the user to input the wind speed in miles per hour, and the temperature in degrees Fahrenheit. The program then outputs the current temperature and the windchill factor. Your program must contain at least two functions: one to get the user input and the other to determine the windchill factor.
#include <iostream>
#include <cmath>
using namespace std;
void Input();
double Wind(double T, double V);
int main()
{
Input();
return 0;
}
void Input()
{
double T;
double V;
cout << "Enter temperature: ";
cin >> T;
cout << "Enter speed in miles per our: ";
cin >> V;
Wind(T, V);
}
double Wind(double T, double V)
{
double windchill = 35.74 + 0.6215 * T - 35.75 * pow(V, 0.16) + 0.4275 * T * pow(V, 0.16);
cout << "Temperature is: " << T << " and windchill factor is: " << windchill << endl;;
return windchill;
}
Comments
Leave a comment