blob: 53ccefd4b759e54421a6f5149d81c8657aebbac2 (
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
|
// BlankConsoleLab.cpp : This file contains the 'main' function. Program execution begins and ends there.
//
#include <iostream>
#include <tgmath.h>
using namespace std;
using std::cout;
using std::cin;
using std::endl;
void convertToF(int *c);
float getChill(int speed, int chill);
int main()
{
char temp = 'f';
int degree=122;
int windSpeed = 232;
float windChill;
cout << "Are you inputting temperature in celcius or fahrenheit? Type C/f? ";
cin >> temp;
if (temp == 'c' || temp == 'C') {
while (degree < -62 || degree > 49.5) {
cout << "What is your temperature in celcius from -62 to 49.5 degrees? ";
cin >> degree;
}
convertToF(°ree);
}
else if (temp == 'f' || temp == 'F') {
while (degree < -80 || degree > 121) {
cout << "What is your temperature in fahrenheit from -80 to 121 degrees? ";
cin >> degree;
}
}
while (windSpeed < 0 || windSpeed > 231) {
cout << "Please input the wind speed in MPH: ";
cin >> windSpeed;
}
windChill = getChill(degree, windSpeed);
cout << "The windchill for " << degree << " degrees Fahrenheit and " << windSpeed << " mph winds is " << windChill;
}
//this convertToF function serves to convert any celcius input to Fahrenheit by taking the input of the degree given and
//performing an algebraic function to convert it. It returns no value because it overwrites the original variable's value.
void convertToF(int *c) {
cout << "Converting Celcius to Farhrenheit..."<< endl;
*c = 9 / 5 * *c + 32;
return;
}
//This getChill function serves to calculate the windchill. I had seperated them all out into segments because I was having
//trouble calulating it right and though it was an order of operations issue, but it was a float issue. This has the inputs of
//the degree temp taken from the user and the wind speed given from the user and returns the calculated value.
float getChill(int temp, int speed) {
cout << "Calculating windchill..."<< endl;
float tempSpeed = pow(speed, .16);
float temp1 = 35.74 + (.6215 * temp);
float temp2 = 35.75 * tempSpeed;
float temp3 = .4275 * temp * tempSpeed;
float chill = temp1 - temp2 + temp3;
return chill;
}
|