From 5dd21829704b6aaefc47f852f4e71bae0b6f3647 Mon Sep 17 00:00:00 2001 From: Trevor Bouchillon Date: Tue, 8 Nov 2022 18:44:31 -0800 Subject: buffing out --- BlankConsoleLab/BlankConsoleLab.cpp | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) (limited to 'BlankConsoleLab/BlankConsoleLab.cpp') diff --git a/BlankConsoleLab/BlankConsoleLab.cpp b/BlankConsoleLab/BlankConsoleLab.cpp index 1a0091d..256ee34 100644 --- a/BlankConsoleLab/BlankConsoleLab.cpp +++ b/BlankConsoleLab/BlankConsoleLab.cpp @@ -11,6 +11,7 @@ using std::endl; float UserInputTemp; float WindSpeed; +char CorF; float CelciusToFarenheit(float Celcius2Farenheit) { @@ -21,14 +22,33 @@ float CelciusToFarenheit(float Celcius2Farenheit) { int main() { - cout << "Please enter a temperature in Celcius: "; + cout << "Please enter a temperature in Celcius or Farenheit: "; cin >> UserInputTemp; - - while (UserInputTemp < -62 || UserInputTemp > 49.5) { - cout << "Please enter a temperature between -62 and 49.5." << endl; - cout << "Please enter a temperature in Celcius: "; - cin >> UserInputTemp; + cout << "If you entered a temperature in Celcius please enter 'C' and if you entered a temperature in Farenheit please enter 'F'. "; + cin >> CorF; + + while (CorF != 'C' && CorF != 'F') { + cout << "Please enter either 'C' or 'F': "; + cin >> CorF; + } + if (CorF == 'F') { + while (UserInputTemp < -80 || UserInputTemp > 121) { + cout << "Please enter a temperature between -80 and 121." << endl; + cout << "Please enter a temperature in Farenheit: "; + cin >> UserInputTemp; + } } + else if (CorF == 'C') { + while (UserInputTemp < -62 || UserInputTemp > 49.5) { + cout << "Please enter a temperature between -62 and 49.5." << endl; + cout << "Please enter a temperature in Celcius: "; + cin >> UserInputTemp; + } + cout << "The temperature you entered is " << CelciusToFarenheit(UserInputTemp) << " degrees in Farenheit." << endl; + } + + + cout << "Please enter a wind speed in Miles Per Hour: "; cin >> WindSpeed; @@ -39,7 +59,7 @@ int main() } - cout << "The temperature you entered is " << CelciusToFarenheit(UserInputTemp) << " degrees in Farenheit." << endl; + //cout << "The temperature you entered is " << CelciusToFarenheit(UserInputTemp) << " degrees in Farenheit." << endl; return 0; } -- cgit v1.2.3