summaryrefslogtreecommitdiff
path: root/BlankConsoleLab/BlankConsoleLab.cpp
blob: b2437271be20a98795945911a80a67eeb0789504 (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
// BlankConsoleLab.cpp : This file contains the 'main' function. Program execution begins and ends there.
//
//nathan turcas lab 2

//psuedo code: First part using three different functions to execute commands so that fahrenheit is inputed and calculated, along with Celcius if 
// inputed and then changed back into Fahrenheit. After that, windspeed is asked to be inputed and then calculated with fahrenheit to produce 
// the windchill.
#include <iostream>

using namespace std;

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

int convertC_to_F(int Ctemp)
{
	float Ftemp;
	Ftemp = Ctemp * 1.8 + 32;
	return Ftemp;
}

float Wind(float Ftemp)
{
	int windspeed;
	while (true)
	{
		string Windspeed;
		

		// take input from the user 
		cout << "Enter a windspeed mph: ";
		cin >> windspeed;
		if (windspeed < 0 || windspeed > 231)
			cout << "windspeed value must be between 0 and 231" << endl;
		else
			break;

	} // end windspeed loop

	float windchill = windspeed * 0.7 - Ftemp;

	return windchill;
}

int main()
{
	string temptype;
	float Ftemp, Ctemp;

	cout << "enter F for Fahrenhiet or C for Celcius: ";
	cin >> temptype; 
	if (temptype == "C")
	{
		while (true)
		{
			// take input from the user 
			cout << "Enter a temperature in Celcius: ";
			cin >> Ctemp;
			if (Ctemp < -62 || Ctemp > 49.5)
				cout << "Celcius value must be between -62 and 49.5" << endl;
			else
				break;
		} //end C while
		
		Ftemp = convertC_to_F(Ctemp);
		
		cout << "Fahrenhiet temperature: "; 
		cout << Ftemp;

	}
	else
	{
		while (true)
		{
			// take input from the user 
			cout << "Enter a temperature in Fahrenheit: ";
			cin >> Ftemp;
			if (Ftemp < -81 || Ftemp > 121)
				cout << "Fahrenheit value must be between -81 and 121" << endl;
			else
				break;
		} // end F while
	}
	
	float windchill = Wind(Ftemp);

	cout << "Windchill: ";
	cout << windchill;
	
}