blob: f9bf9b21a1d95942c7d7ac69470cf9aec76cc0ad (
plain) (
blame)
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
64
65
66
67
68
69
70
71
72
|
#include <iostream>
using namespace std;
using std::cout;
using std::cin;
using std::endl;
using std::string;
char y;
char n;
int fahrenheit(int t);
//changes celsius to farenheit
int fahrenheit(int x)
{
int f{};
//f = (t * (9 / 5)) + 32;
f = (9 / 5) * x + 32;
return f;
}
int main()
{
float x{};
int f{};
float w{};
float wc{};
char choice{};
//collects a temp
cout << "Enter a temperature between -80 and 121: ";
cin >> x;
//makes sure temp is between -80 and 121
if (x < -80 || x > 121)
{
cout << "Input invalid, please enter a number between -80 and 121" << endl;
cin.ignore(99, '\n');
}
cout << "type y or n," << " is the tempterature in fahrenheit?"<<endl;
if ('n')
{
f = fahrenheit(x);
}
else if (choice == 'y')
{
cin >> f;
}
//collects windspeed
cout << "Enter a wind speed between 0 and 231: ";
cin >> w;
//windspeed between 0-231
if (w < 0 || w > 231)
{
cout << "Input invalid, please enter a number between 0 and 231" << endl;
cin.ignore(99, '\n');
}
//f = temp w = wind
wc = (35.74 + 0.6215 * f - 35.75 * pow(w, 0.16) + .4275 * f * pow(w, 0.16));
//displays wind, temp, and windchill
cout << w << " wind" << endl;
cout << f << " temp" << endl;
cout << wc << " wind chill" << endl;
}
|