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
|
// BlankConsoleLab.cpp : This file contains the 'main' function. Program execution begins and ends there.
//
#include <iostream>
using namespace std;
float C_to_F(float x);
void getUserInputs(float& value, float min, float max, string type);
float calculate(float mph, float degrees);
//m is min; M is max
const float Fm = -80;
const float FM = 121;
const float Cm = -62;
const float CM = 49.5;
const float Wm = 0;
const float WM = 231;
float C_to_F(float x)
{
x *= 1.8;
x += 32;
return x;
}
void getUserInputs(float& value, float min, float max, string type)
{
while (value <= min || value >= max)
{
cout << "What is the value of " << type << "?" << endl;
cout << "(Enter a value between " << Fm << " & " << FM << ")" << endl;
cin >> value;
}
}
float calculate(float mph, float degrees)
{
return (35.74 + (0.6215 * degrees) - (35.75 * pow(mph, 0.16)) + (0.4275 * degrees * pow(mph, 0.16)));
}
int main()
{
string CorF;
float temp;
float wSpeed;
while (CorF != "C" && CorF != "F")
{
cout << "Do you want to enter in Fahrenheit (F) or Celsius (C)" << endl;
cin >> CorF;
}
if (CorF == "F")
{
getUserInputs(temp, Fm, FM, "Fahrenheit");
}
else
{
getUserInputs(temp, Cm, CM, "Celcius");
temp = C_to_F(temp);
cout << "That is " << temp << " degrees in Fahrenheit" << endl;
}
getUserInputs(wSpeed, Wm, WM, "Wind Speed");
}
|