Hi, I am supposed to write code for a program that calculates the wind chill index based on the temperature and wind speed entered by the user. Then I have to use a void function which has to "cout" the effect based on the windchill. I can get the program to output the windchill but can't get the void function to work. Please help. Thanks!
Code:#include <iostream> #include <cmath> using namespace std; double windchill_calculator(double temperature, double windspeed); void effect(double windchill); int main() { double w; double temperature; double windspeed; do { cout << "Enter the air temperature in degree Celsius: "; cin >> temperature; cout << "Enter the wind speed in kilometres per hour (km/h): "; cin >> windspeed; if (windspeed < 0) cout << "The windspeed must be greater or equal to 0"<< endl<< endl; } while (windspeed < 0); if (windspeed > 4.8) w = windchill_calculator(temperature, windspeed); else if (windspeed >= 0 && windspeed <= 4.8) w = temperature; cout << "The wind chill index is " << w << endl; effect(w); } double windchill_calculator(double temperature, double windspeed) { double windchill = 13.12 + (0.6215*temperature) - (11.37*(pow(windspeed,0.16))) + (0.3965*temperature*pow(windspeed,0.16)); return windchill; } void effect(double windchill) { if (windchill >= 0 && windchill < -25) { cout<< "Discomfort"<< endl; } else if (windchill >= -25 && windchill < -45) { cout<< "Risk of skin freezing (frostbite)"<< endl; } else if (windchill >= -45 && windchill < -60) { cout<< "Exposed skin may freeze within minutes"<< endl; } else if (windchill >= 60) { cout<< "Exposed skin may freeze in under 2 minutes"<< endl; } return; }



LinkBack URL
About LinkBacks


