In cold weather meteorologists report an index called the wi
Solution
Please follow the code and comments for description :
CODE :
#include <iostream> // required header files for the code
#include <cmath>
using namespace std;
float windChillIndex (float temperature, float windspeed) { // function that returns the wind index for the given temperature and speed
float windindex = 35.74f + 0.6215f * temperature; // initialising the wind index
windindex -= 35.75f * pow(windspeed, 0.16f); // calculating the index values
windindex += 0.4275f * temperature * pow(windspeed, 0.16f);
return windindex; // returning the index result value
}
int main() // driver method
{
cout << \"Welcome to Wind Chill Index Calculator.!\" << endl; // prompt for the user about the code
cout << \"Enter the Temperature (in Celsius <= 10) : \" << endl; // prompt to enter the data
float temp = 0;
cin >> temp; // getting the data
if(temp < 0 || temp > 10){ // checking for the entered data temperature
cout << \"Invalid Temperature.!\" << endl;
exit(0); // exiting the code
}
cout << \"Enter the Wind Speed (in m/sec) : \" << endl; // prompt to enter the speed of the wind
float windSpeed = 0;
cin >> windSpeed; // getting the data
float windIndex = windChillIndex (temp, windSpeed); // calculating the result by calling the function
cout << \"The Resultant Wind Chill Index is : \" << windIndex << \" C\"<< endl; // printing the result in celsius format
return 0;
}
OUTPUT :
Welcome to Wind Chill Index Calculator.!
Enter the Temperature (in Celsius <= 10) :
10
Enter the Wind Speed (in m/sec) :
50
The Resultant Wind Chill Index is : -16.9024 C
Hope this is helpful.
