### wind chill and heat index HELP PLEASE

guys i need to write a program to calculate wind chill or heat index. wind chill only applies when the temperature is less than or equal to 10degreeC. e heat index calculation only applies when the temperature is less than or equal to 80degreeF. wind chill=33-(10sqrt(v)-v+10.5)*(33-t)/23.1
heat index = c1 + c2T+ c3R + c4TR+ c5 T^2+ c6R^2+ c7T^2R+ c8 TR^2+ c9T^2R^2
guys this is my code so far. i did the temperature conversion but i am unable to think beyond this. please help me in getting this finished.

 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263`` ``````#include #include #include using namespace std; // Delete these, perhaps: int getF (int celsius); int getC (int fahrenheit); void getTemp(int & t); // Returned by reference string getScale(); // Returned by value void printConverted(int temp, string scale); int main () { int temp; string scale; getTemp(temp); scale = getScale(); printConverted(temp, scale); return 0; } void getTemp(int & t) { cout << "Enter a temperature: "; cin >> t; } string getScale() { string s; cout << "Enter the scale: "; cin >> s; while (s != "F" && s != "C" && s != "f" && s != "c") { cout << "Quit fooling around. F or C, please: "; cin >> s; } return s; } void printConverted(int temp, string scale) { if (scale == "F" || scale == "f") { cout << getC(temp) << "C" << endl; } else { cout << getF(temp) << "F" << endl; } } int getF (int celsius) { return celsius * 9 / 5 + 32; } int getC (int fahrenheit) { return (fahrenheit - 32) * 5 / 9; }``````
Last edited on
`#include<string> `

You're missing this line at the top.

Hold on, I'll write some optimized code.
 ``12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152`` ``````#include #include #include class converter { private: typedef int(*callback_t)(int); int input; char c; std::map functions; static int getF (int celsius) { return celsius * 9 / 5 + 32; } static int getC (int fahrenheit) { return (fahrenheit - 32) * 5 / 9; } public: void getinput() { std::cout << "enter number: "; std::cin >> input; do { std::cout << "enter conversion format: F or C\n"; std::cin >> c; }while( ! (c == 'F' || c == 'C') ); } void callfunction() { std::cout << functions[c](input); } converter() { functions['C']= &getC; functions['F']= &getF; } }; int main() { converter conv; conv.getinput(); conv.callfunction(); }``````

Here you go.
hey nexius thanx for the code but i want to calculate wind chill and heat index can you please help me get started there
From NOAA:

Heat index formula based on multiple regression analysis:

HI = -42.379 + 2.04901523T + 10.14333127R - 0.22475541TR - 6.83783x10 -3T2 - 5.481717x10 - 2R2 + 1.22874x10 - 3T2R + 8.5282x10 - 4TR2 - 1.99x10
- 6T2R2
where T = ambient dry bulb temperature (°F)
R = relative humidity (integer percentage)

Wind chill formula:

WC = 35.74 + 0.6215T + 35.75(V ^0.16) + 0.4275T(V^0.16)
where T = Air Temp (°F)
V = wind speed (mph)
Topic archived. No new replies allowed.