During winter when it is very cold typically everyone would

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 windchill factor.

Your program must contain at least two functions: one to get the user input and the other to determine the windchill factor.

The main function is not considered to be one of two functions. That function is always included. Also, the functions must include data being passed to them and if necessary a value returned.

Hint: ideally the function for user input is a void function passing parameters by reference and the windchill function should be a value-returning function.

Solution

#include <iostream>
#include <cmath>
#include <iomanip>

using namespace std;

//windchill funciton which calculates the factor
double windchill(double wind,double temp)
{
    return 35.74 + 0.6215 * temp - 35.75 * pow(wind, 0.16) + 0.4275 * temp * pow(wind,0.16);
}
//prompts the user for values and passes it to other funciton
void read()
{
    double wind, temp;
    cout << \"Enter the wind speed in miles per hour: \";
    cin >> wind;
    cout << \"Enter the temperature in fahrenheit: \";
    cin >> temp;
    cout << \"Windchill factor \" << setprecision(4) << fixed << windchill(wind, temp) << endl;
}

int main()
{
    read();
   return 0;
}

Output:
Enter the wind speed in miles per hour: 88
Enter the temperature in fahrenheit: 11
Windchill factor -20.9776

During winter when it is very cold, typically, everyone would like to know the windchill factor, especially, before going out. Meteorologists use the following

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site