summaryrefslogtreecommitdiff
path: root/BlankConsoleLab/CST116-Lab2-Bold.cpp
blob: 8abed138f36111a3010eb336c9c7eb076351e9f2 (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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#include <iostream>
#include <fstream>
#include <iomanip>

using std::cin;
using std::cout;
using std::endl;

float Convertor(float&);
// CtoF - converts temperature in C to F.
// @param - Celcius is passed by reference.
float WindChill(float, float);
// WindChill - calculates the wind chill temp. 
// @param - Fahrenheit is passing by value.
// @param - wind speed in mph is passing by value.

int main() {

	char option = 0;
	float tempF = 0;
	float tempC = 0;
	float mph = 0;
	float CtoF = 0;
	float Fahr = 0;

	while (option != 'f' && option != 'F' && option != 'c' && option != 'C') {
		cout << "Please enter F for Fahrenheit or C for Celsius: ";
		cin >> option;
	}

	if (option == 'f' || option == 'F')
	{
		cout << "\n\nPlease enter your temperature between -80 and 121: ";
		cin >> tempF;

		while (tempF <= -81 || tempF >= 122) {
			cout << "Enter your temperature between -80 and 121: ";
			cin >> tempF;
		}

		tempC = (tempF - 32) * 1.8;
		cout << "\nYour entry is  " << tempF << " Fahrenheit and it is " << tempC << " in Celsius." << "\n\n";


		while (mph <= -1 || mph >= 232)
		{
			cout << "Now, enter your wind speed in miles between 0 and 231: ";
			cin >> mph;
		}
		cout << "\nYour wind speed is " << mph << " miles per hour!\n\n";

	}

	else if (option == 'c' || option == 'C')
	{
		cout << "\n\nPlease enter your tempareture between -62 and 49.5: ";
		cin >> tempC;

		while (tempC <= -63 || tempC >= 49.6)
		{
			cout << "Enter your temperature between -62 and 49.5: ";
			cin >> tempC;
		}

		tempF = tempC * 1.8 + 32;

		cout << "\nYour entry is " << tempC << " and it is " << tempF; cout << " Fahrenheit.\n";
		while (mph <= 0 || mph >= 231)
		{
			cout << "\n\nNow, enter your wind speed in miles between 0 and 231: ";
			cin >> mph;
		}
		cout << "\nYour wind speed is " << mph << " miles per hour!\n\n";

	}


	float Convertor(tempC);

	float chill = WindChill(tempF, mph);

	cout << "\tFahrenheit\t" << tempF << "\n";
	cout << "\tCelsius\t\t" << tempC << "\n";
	cout << "\tWind Speed\t" << mph << "\n";
	cout << "\tWind Chill\t" << chill << "\n\n";

	
	return 0;
}

float Convertor(float& tempC)
{
	float Fahr = 0;

	Fahr = tempC * 1.8 + 32;

	return 0.0f;
}

float WindChill(float tempF, float mph)
{
	float chill = 0;

	chill = 35.74 + .6215 * (tempF)-35.75 * pow(mph, 0.16) + 0.4275 * (tempF)*pow(mph, 0.16);

	return chill;
}