Question

Wind Chill («F) = 35.74 +0.621 5T-35.75(V0.16) + 0.4275T(V0.16) where,T= Air Temperature (明v-wind Speed (mph) Effective 11/01/01

Part​ ​A

Write a function windChillCalculator ​to determine the wind chill. Your main function should take in user inputs for T (air temperature) and V (wind speed) and pass these values as parameters to your function. After your function calculates the wind chill it should return​ it to main. To test your code, for T = 30.0 and V = 5.0, you should get a Wind Chill of 24.7268. Within your main function, print the following cout statement: cout << "The wind chill is " << wind_chill << " degrees F." << endl; HINT​: Look at the pow()​ function in the C++ math.h library

Part​ ​B

Once you have the wind chill calculation working, create another function printWindChill​. This function should call windChillCalculator and print all the wind chill values for a fixed temperature and variable wind speeds. You will need to write a loop in this function to iterate over the different wind speeds. The function should receive T (air temperature), low_wind_speed, high_wind_speed, and wind_speed_step as input parameters. For Example: Let the input parameters be T = 30.0, low_wind_speed = 5.0, high_wind_speed = 8.0, and wind_speed_step = 1.0, your function should print out the wind chill for a temperature of 30 °F and wind speeds starting from 5 mph and ending at 8 mph, incrementing by 1 mph. (5 mph, 6 mph, 7 mph, and 8 mph) Use the following cout statement to output the values from within​ ​the​ ​function​: cout << "The wind chill is " << wind_chill << " degrees F for an airtemperature of " << T << " degrees F" << " and a wind speed of " << V << " mph." << endl;

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Part A:

Screenshot of the code:

/Include the required header file. #include iostream» #include<math.h> using namespace std; //Define the function. float wind

Output:

Enter the air temperature:3 Enter the wind speed: 5.e The wind chill is 24.7268 degrees F and a wind speed of 5 mph.

Code to copy:

//Include the required header file.

#include <iostream>

#include<math.h>

using namespace std;

//Define the function.

float windChillCalculator(float T, float V)

{

    //Claculate the wind chill.

    float wind_chill=35.74 + 0.6215*T - 35.75*

                (float)(pow(V,0.16)) + 0.4275*T*

                (float)(pow(V,0.16));

   

    //Return the wind child.

    return wind_chill;

}

//Define the main function.

int main()

{

//Declare the variables.

float V, T, wind_chill;

//Prompt the user for input.

cout<<"Enter the air temperature:";

cin>>T;

cout<<endl<<"Enter the wind speed:";

cin>>V;

//Call the windChillCalculator() function

//to retrieve the wind_chill value.

wind_chill = windChillCalculator(T, V);

//Display the results.

cout << "The wind chill is " << wind_chill

       << " degrees F" << " and a wind speed of "

       << V << " mph." << endl;;

return 0;

}

Part B:

Screenshot of the code:

//Include the required #include <iostream> # include<math. h> header file. using namespace std //Declare the function. float//Increase the speed V -V+ wind speed_step: //Define the function float windChǐllCalculator (float T, float v) //Claculate th

Output:

Enter the air temperature: 30.e Enter the low wind speed: 5.e Enter the high wind speed: 8.0 Enter the wind speed step: 1 The

Code to copy:

//Include the required header file.

#include <iostream>

#include<math.h>

using namespace std;

//Declare the function.

float windChillCalculator(float T, float V);

//Define the function.

void printWindChill()

{

     //Declare the variable.

     float T, V, low_wind_speed, high_wind_speed,

wind_speed_step, wind_chill;

     //Prompt the user for input.

     cout << "Enter the air temperature:";

     cin >> T;

     cout << endl << "Enter the low wind speed:";

     cin >> low_wind_speed;

     cout << endl << "Enter the high wind speed:";

     cin >> high_wind_speed;

     cout << endl << "Enter the wind speed step:";

     cin >> wind_speed_step;

     //Evaluate the iterations.

     int n = (high_wind_speed - low_wind_speed) /

wind_speed_step;

     V = low_wind_speed;

     //Iterate through the loop.

     for (int i = 0; i< n + 1; i++)

     {

          //Call the windChillCalculator() function

          //to retrieve the wind_chill value.

          wind_chill = windChillCalculator(T, V);

          //Display the details.

          cout << "The wind chill is " << wind_chill

              << " degrees F for an airtemperature of "

<< T << " degrees F" << " and a wind speed of "

              << V << " mph." << endl;

          //Increase the speed.

          V = V + wind_speed_step;

     }

}

//Define the function.

float windChillCalculator(float T, float V)

{

     //Claculate the wind chill.

     float wind_chill = 35.74 + 0.6215*T - 35.75*

          (float)(pow(V, 0.16)) + 0.4275*T*

          (float)(pow(V, 0.16));

     //Return the wind child.

     return wind_chill;

}

//Define the main function.

int main()

{

     //Call the printWindChill() function.

     printWindChill();

     return 0;

}

Add a comment
Know the answer?
Add Answer to:
Part​ ​A Write a function windChillCalculator ​to determine the wind chill. Your main function should take...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT