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.

Respuesta :

Here is code in C++.

#include <bits/stdc++.h>

using namespace std;

// function to get input from user.

// here parameters are passed by reference

void get_inp(double &V, double &T)

{

cout << "Enter the wind speed in miles per hour: ";

cin >> V;

cout << "Enter the temperature in degrees Fahrenheit: ";

cin >> T;

}

//function to Calculate and return windChill factor.

double windChill(double &V, double &T)

{

double factor = 35.74 + (0.6215 * T) - (35.75 * V * 0.16) + (0.4275 * T * V * 0.16);

return factor;

}

// main function

int main()

{

//declare variables to store temperature and wind speed

double V, T;

// calling get_inp() to get input from user

get_inp(V, T);

/* calling w_c_fact() to Calculate windChill factor and

assign it to variable "w_c_fact".*/

double w_c_fact = windChill(V, T);

//printing the output

cout <<"The windchill factor "<<w_c_fact<<endl;

return 0;

}

Explanation:

Create two variables "V" & "T" to store the wind speed and temperature.In the function get_inp(), these variables are passed by reference and ask user to give input. Value of Wind speed and temperature are assigned to V & T respectively. then pass these value to function windChill() to Calculate the wind chill factor according to the given equation.This function will return the factor after calculation and assigned to "w_c_fact" variable.Print this factor.

Output:

Enter the wind speed in miles per hour: 37.5

Enter the temperature in degrees Fahrenheit: 110.2

The windchill factor 172.392