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.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include <iostream>
#include <string>
#include <cmath>

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.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include <iostream>
#include <string>
#include <map>

class converter
{
private:
	typedef int(*callback_t)(int);
	int input;
	char c;
	std::map<char, callback_t> 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.