summaryrefslogtreecommitdiff
path: root/BlankConsoleLab/BlankConsoleLab.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'BlankConsoleLab/BlankConsoleLab.cpp')
-rw-r--r--BlankConsoleLab/BlankConsoleLab.cpp131
1 files changed, 82 insertions, 49 deletions
diff --git a/BlankConsoleLab/BlankConsoleLab.cpp b/BlankConsoleLab/BlankConsoleLab.cpp
index 47e24c5..babd152 100644
--- a/BlankConsoleLab/BlankConsoleLab.cpp
+++ b/BlankConsoleLab/BlankConsoleLab.cpp
@@ -16,94 +16,127 @@ float WindChill;
float WindSpeed;
-void welcomeMessage()
-{
- //Welcome Message
- cout<< "Welcome to the Menu!!" << endl;
-}
+
void printFunctionCF()
{
- //Print Functionn for Celcius to Fahrenheit
+ //Print Functionn for Celsius to Fahrenheit
cout << "For " << Fah << " Degrees f and " << WindSpeed << " mph winds the windchill is: " << WindChill << endl;
}
void printFunctionFC()
{
- cout << "For " << Cel << " Degrees c and " << WindSpeed << " mph winds the windchill is: " << WindChill << endl;
+ //PrintFunction to Celsius To Fahrenheit
+ cout << "For " << Cel << " Degrees c and " << WindSpeed << " kmh winds the windchill is: " << WindChill << endl;
}
//Celcius to Fahrenheit
int CeltoFar()
{
+ cout << "Type your temprature in Celcius: ";
+ cin >> Cel;
+ cout << endl;
- cout << "Type your temprature in Celcius: ";
- cin >> Cel;
- cout << endl;
-
- cout << "You entered " << Cel << endl;
+ if (Cel > -62 && Cel < 49.5)
+ {
+ cout << "You entered " << Cel << endl;
- Fah = 9 / 5 * Cel + 32; ;
+ Fah = 9 / 5 * Cel + 32; ;
- cout << "which is " << Fah << " degrees fahrenheit" << endl;
+ cout << "which is " << Fah << " degrees fahrenheit" << endl;
+ }
+ else
+ {
+ cout << "Please Try again" << endl;
+ cout << "Type your temprature in Celcius: ";
+ cin >> Cel;
+ cout << endl;
+ }
cout << "Type the windspeed in mph " << endl;
cin >> WindSpeed;
- WindChill = 35.74 + .6215 * Fah - 35.75 * pow(WindSpeed, .16) + .4275 * Fah * pow(WindSpeed,.16);
+ if (WindSpeed > 0 && WindSpeed < 231)
+ {
+ WindChill = 35.74 + .6215 * Fah - 35.75 * pow(WindSpeed, .16) + .4275 * Fah * pow(WindSpeed, .16);
+ }
+ else
+ {
+ cout << "Please Try again" << endl;
+ cout << "Type the windspeed in mph " << endl;
+ cin >> WindSpeed;
+ }
return WindChill;
return WindSpeed;
return Fah;
}
+int FahtoCel()
+{ //Fahrenheit to Celcius
+ while (Fah > -79.6 && Fah <121.1)
+ {
+ cout << "Type your temprature in Fahrenheit: ";
+ cin >> Fah;
+ cout << endl;
+ }
+ if (Fah <= -79.6 || Fah >= 121.1)
+ {
+ cout << "You entered " << Fah << endl;
+ Cel = (Fah - 32) * 5 / 9;
+ cout << "which is " << Cel << " degrees celcius" << endl;
+ }
-int FahtoCel()
-{
-
- //Fahrenheit to Celcius
- cout << "Type your temprature in Fahrenheit: ";
- cin >> Fah;
- cout << endl;
-
- cout << "You entered " << Fah << endl;
-
- Cel = (Fah - 32) *5/9;
-
- cout << "which is " << Cel << " degrees Celcius" << endl;
-
- cout << "Type the windspeed in mph " << endl;
- cin >> WindSpeed;
-
- WindChill = 35.74 + .6215 * Cel -35.75 * pow(WindSpeed, .16) + .4275 * Cel * pow(WindSpeed, .16);
+ while (WindSpeed < 0 && WindSpeed > 371)
+ {
+ cout << "Type the windspeed in Km " << endl;
+ cin >> WindSpeed;
+ }
+ //windspeed in Kilometers
+ WindChill = 13.12 + .6215 * Cel - 11.37 * pow(WindSpeed, .16) + .3965 * Cel * pow(WindSpeed, .16);
+
return WindChill;
return WindSpeed;
return Cel;
}
-//Driver Program
-int main()
+void menuChoice(char& Cel)
{
+ char CH = Sel;
- welcomeMessage();
+
+ if (CH == 'C' || CH == 'c')
+ {
+ CeltoFar();
+ printFunctionCF();
+ }
+ else if (CH == 'F' || CH == 'f')
+ {
+ FahtoCel();
+ printFunctionFC();
+ }
- cout << "Cel or Fah" << endl << "Please type C or F: ";
- cin >> Sel;
- if (Sel == 'C' || Sel == 'c')
- {
- CeltoFar();
- printFunctionCF();
- }
- else if (Sel == 'F' || Sel == 'f')
- {
- FahtoCel();
- }
- else
+}
+int welcomeMessageChoice()
+{
+
+ //Welcome Selection
+ cout << "Welcome to the Menu!!" << endl;
+ while (Sel != 'C' && Sel != 'c' && Sel != 'f' && Sel != 'F')
{
- cout << "Please try again." << endl << "Remember you can only type C or F: ";
+ cout << "Cel or Fah" << endl << "Please type C or F: ";
cin >> Sel;
}
+ menuChoice(Sel);
+ return Sel;
+
+}
+//Driver Program
+int main()
+{
+ welcomeMessageChoice();
+ menuChoice(Sel);
}