summaryrefslogtreecommitdiff
path: root/BlankConsoleLab/BlankConsoleLab.cpp
blob: 2a1caf05af8c4bff22a17c8936545b64d8cfe0d5 (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
// BlankConsoleLab.cpp : This file contains the 'main' function. Program execution begins and ends there.
/*
* Benjamin Smith
* CST116 Lab 2
*/

#include <iostream>

using namespace std;

string input = "";
float temperature = 0;

int main()
{
	cout << "Before you input a temperature value, you must first determine if it's in fahrenheit or celcius." << endl;
	cout << "Please input 'F' for fahrenheit or 'C' for celcius: ";
	cin >> input;
	while (input != "F" && input != "C") {
		cout << "That input is invalid." << endl;
		cout << "Make sure your input is capitalized." << endl;
		cout << "Please input 'F' for fahrenheit or 'C' for celcius: ";
		cin >> input;
	}
	
	cout << endl << endl << "Now please input the temperature: ";
	cin >> temperature;
	if (input == "C") {
		while (temperature < -62 || temperature > 49.5) {
			cout << "That input is invalid." << endl << "Your value must be between -62 and 49.5." << endl;
			cout << "Please input the temperature: ";
			cin >> temperature;
		}
	}
	else {
		while (temperature < -80 || temperature > 121) {
			cout << "That input is invalid." << endl << "Your value must be between -80 and 121." << endl;
			cout << "Please input the temperature: ";
			cin >> temperature;
		}
	}

	if (input == "C") {
		temperature *= 1.8;
		temperature += 32;
	}
}