Problem With Function Calculation

#include <iostream>
#include <cmath>
using namespace std;
int main()
{
float windSpeed;
float temperature;
cout << "Please type in the temperature in degrees Celsius.\n";
cin >> temperature;
if (temperature > 10)
{
cout << "The value you entered violates the temperature restriction.\n";
return 0;
}
else
{
cout << "Please type in the wind speed in meters per second.\n";
cin >> windSpeed;
cout << "The wind chill index is " << 33 - (((10 * sqrt(windSpeed) - windSpeed + 10.5) * (33 - temperature)) / 23.1) << " degrees Celsius.\n";
}
return 0;
}

The problem I'm having is this. Let us say that I plug in a number such as 9 or 10 for windSpeed and temperature. The program works fine. Now instead, if I plug in 20 in for one of the values, the output gets way off. What is going on with my code? Any help would be greatly appreciated!
Last edited on
Well, the program won't let you input anything greater then 10 when asking for the temperture. Have you tried just doing the math on a piece of paper to see if it's correct? I can't imagine why the calculation would result in a different result because you used a different wind speed.
Thank you pogrady! I looked back over my math and found a few errors. You were correct; the program does not give me wrong results.
Topic archived. No new replies allowed.