aboutsummaryrefslogtreecommitdiff
path: root/homework2/homework2.cpp
blob: 4ade128610e0ac730705fb4cc8e56c606f73fbc8 (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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
// Author: Connor McDowell
// Date: 1/20/24
// project reason: Homework 2
#include <iostream>
#define VERBOSE
using std::cout;
using std::cin;
using std::endl;


int main()
{
	char i;

	std::cout << "Please enter C if you would like to change fahrenheit to celsius ";

	std::cout << "Or enter F if you would like to change celsius to fahrenheit ";

	cin >> i;

	if ( i == 'C')
	{
		float fah = 0.0;

		std::cout << "you have selected fahrenheit to celsius, please enter a whole number below" << std::endl;

		cin >> fah;

		float num = (fah - 32) * (5 / 9);

		if (-8 < num && num < 5)
		{
			std::cout << "The temperature: " << num << " fahrenheit, is cold enough that water freezes! brrr!" << std::endl;
		}

		if (6 < num && num < 15)
		{
			std::cout << "The temperature: " << num << " fahrenheit, is quite chilly! bring a sweater" << std::endl;
		}

		if (15 < num && num < 24)
		{
			std::cout << "The temperature: " << num << " fahrenheit, is around room temperature and quite comfortable" << std::endl;
		}

		if (25 < num && num < 30)
		{
			std::cout << "The temperature: " << num << " fahrenheit, is pretty warm! drink plenty of water and stay in the shade when you can." << std::endl;
		}

		if (31 < num && num < 39)
		{
			std::cout << "The temperature: " << num << " fahrenheit, is very hot, wear sunscreen and hydrate often if going out." << std::endl;
		}

		if (num > 40)
		{
			std::cout << "The temperature: " << num << " fahrenheit, do not even think about leaving the house." << std::endl;
		}
		#ifdef VERBOSE
		{
			std::cout << fah << " F to C" << std::endl;
			std::cout << "C = (" << fah << " - 32) * (5/9)" << std::endl;
			std::cout << "C = " << num << " " << std::endl;
		}
		#endif VERBOSE
	}

	// DONE
	if ( i == 'F')
	{
		float cel = 0.0;

		std::cout << "you have selected celsus to fahrenheit, please enter a whole number below" << std::endl;

		cin >> cel;

		float num = (cel * (9.0 / 5.0)) + 32;

		if (0 < num && num < 32)
		{
			std::cout << "The temperature: " << num << " fahrenheit, is cold enough that water freezes! brrr!" << std::endl;
		}

		if (33 < num && num < 65)
		{
			std::cout << "The temperature: " << num << " fahrenheit, is quite chilly! bring a sweater" << std::endl;
		}

		if (66 < num && num < 76)
		{
			std::cout << "The temperature: " << num << " fahrenheit, is around room temperature and quite comfortable" << std::endl;
		}

		if (78 < num && num < 88)
		{
			std::cout << "The temperature: " << num << " fahrenheit, is pretty warm! drink plenty of water and stay in the shade when you can." << std::endl;
		}

		if (89 < num && num < 100)
		{
			std::cout << "The temperature: " << num << " fahrenheit, is very hot, wear sunscreen and hydrate often if going out." << std::endl;
		}

		if (num > 101)
		{
			std::cout << "The temperature: " << num << " fahrenheit, do not even think about leaving the house." << std::endl;
		}
		#ifdef VERBOSE
		{
			std::cout << cel << " C to F" << std::endl;
			std::cout << "F = 32 + (9/5 * " << cel << " C)" << std::endl;
			std::cout << "F = " << num << " " << std::endl;
		}
		#endif VERBOSE
	}
	system("pause");
	return 0;
}

float FtoC(float fah)
{
	// -32*5/9

	float num = (fah - 32) * (5 / 9);

	return num;
}