summaryrefslogtreecommitdiff
path: root/BlankConsoleLab/BlankConsoleLab.cpp
diff options
context:
space:
mode:
authorTrevor Bouchillon <[email protected]>2022-11-09 12:41:38 -0800
committerTrevor Bouchillon <[email protected]>2022-11-09 12:41:38 -0800
commit3aac1ede42dca870cb279b90482b757c7b953b6a (patch)
tree93f2e588fa41dc50a4e540ae4a2d4f593226b9fd /BlankConsoleLab/BlankConsoleLab.cpp
parentbuffing out (diff)
downloadcst116-lab2-daboochillin-3aac1ede42dca870cb279b90482b757c7b953b6a.tar.xz
cst116-lab2-daboochillin-3aac1ede42dca870cb279b90482b757c7b953b6a.zip
Finished Code
Diffstat (limited to 'BlankConsoleLab/BlankConsoleLab.cpp')
-rw-r--r--BlankConsoleLab/BlankConsoleLab.cpp37
1 files changed, 25 insertions, 12 deletions
diff --git a/BlankConsoleLab/BlankConsoleLab.cpp b/BlankConsoleLab/BlankConsoleLab.cpp
index 256ee34..085e6f1 100644
--- a/BlankConsoleLab/BlankConsoleLab.cpp
+++ b/BlankConsoleLab/BlankConsoleLab.cpp
@@ -2,35 +2,37 @@
//
#include <iostream>
+#include <math.h>
+#include <stdio.h>
using namespace std;
using std::cout;
using std::cin;
using std::endl;
+using std::pow;
float UserInputTemp;
float WindSpeed;
char CorF;
+float windchill;
float CelciusToFarenheit(float Celcius2Farenheit) {
- Celcius2Farenheit = (UserInputTemp * (9 / 5)) + 32;
+ Celcius2Farenheit = (UserInputTemp * (static_cast<float>(9) / 5)) + 32;
return Celcius2Farenheit;
}
-int main()
-{
-
+float GetTemp() {
cout << "Please enter a temperature in Celcius or Farenheit: ";
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;
-
+ 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;
@@ -46,10 +48,10 @@ int main()
}
cout << "The temperature you entered is " << CelciusToFarenheit(UserInputTemp) << " degrees in Farenheit." << endl;
}
-
-
-
+ return UserInputTemp;
+}
+float GetWindSpeed() {
cout << "Please enter a wind speed in Miles Per Hour: ";
cin >> WindSpeed;
while (WindSpeed < 0 || WindSpeed > 231) {
@@ -57,9 +59,20 @@ int main()
cout << "Please enter a wind speed in Miles Per Hour: ";
cin >> WindSpeed;
}
+ return WindSpeed;
+}
-
- //cout << "The temperature you entered is " << CelciusToFarenheit(UserInputTemp) << " degrees in Farenheit." << endl;
+float WindChill() {
+ windchill = 35.74 + (0.6215 * CelciusToFarenheit(UserInputTemp)) - (35.75 * pow(WindSpeed, 0.16)) + (0.4275 * CelciusToFarenheit(UserInputTemp) * pow(WindSpeed, 0.16));
+ cout << "Based on your inputs of " << CelciusToFarenheit(UserInputTemp) << " and " << WindSpeed << ", the wind chill is " << windchill << ".";
+ return windchill;
+}
+
+int main()
+{
+ GetTemp();
+ GetWindSpeed();
+ WindChill();
return 0;
}