summaryrefslogtreecommitdiff
path: root/BlankConsoleLab/BlankConsoleLab.cpp
diff options
context:
space:
mode:
authorJoe Traver <[email protected]>2022-11-07 20:39:48 -0800
committerJoe Traver <[email protected]>2022-11-07 20:39:48 -0800
commit60198fbe710289ecf0e1301c3e47ed1d232ae896 (patch)
tree26ae47d44a66ec32ca9714a2c74c779ae662e12a /BlankConsoleLab/BlankConsoleLab.cpp
parentPseudo Code (diff)
downloadcst116-lab2-joetraver30-60198fbe710289ecf0e1301c3e47ed1d232ae896.tar.xz
cst116-lab2-joetraver30-60198fbe710289ecf0e1301c3e47ed1d232ae896.zip
Code (Completed on personal file before realizing there was a git hub repository)
Diffstat (limited to 'BlankConsoleLab/BlankConsoleLab.cpp')
-rw-r--r--BlankConsoleLab/BlankConsoleLab.cpp169
1 files changed, 169 insertions, 0 deletions
diff --git a/BlankConsoleLab/BlankConsoleLab.cpp b/BlankConsoleLab/BlankConsoleLab.cpp
index 8b13789..bcb3304 100644
--- a/BlankConsoleLab/BlankConsoleLab.cpp
+++ b/BlankConsoleLab/BlankConsoleLab.cpp
@@ -1 +1,170 @@
+// CST116-lab2-joetraver30.cpp
+#include <iostream>
+#include <math.h>
+#include <stdio.h>
+
+using std::cout;
+using std::cin;
+using std::endl;
+
+void GetInfo(char& letter, float& t, float& T, int& W);
+float FahrenheitConversion(float T);
+float WindChillCalculation(int W, float t);
+
+
+int main()
+{
+ char letter = {};
+ float T = 0;
+ int W = 0;
+ float t = 0;
+ float C = 0;
+
+
+ GetInfo(letter, t, T, W);
+
+ if (letter == 'c' || letter == 'C')
+ t = FahrenheitConversion(T);
+
+ cout << "Temperature is: " << t << " Degrees Fahrenheit" << endl << endl;
+
+ cout << "Wind speed is: " << W << " MPH" << endl << endl;
+
+
+
+ C = WindChillCalculation(W, t);
+
+ cout << "For " << t << " degrees F and " << W << " MPH, the windchill is: " << C << endl;
+
+
+}
+
+//compiles information from the user
+void GetInfo(char& letter, float& t, float& T, int& W)
+{
+
+
+ cout << "Enter temperature units Celcius or Fahrenheit (C/F): ";
+ cin >> letter;
+
+ cout << endl;
+
+ //error check
+ while (!((letter == 'c') || (letter == 'C') || (letter == 'f') || (letter == 'F')))
+ {
+
+ cout << "ERROR: a F or C must be entered";
+
+ cin.clear();
+
+ cin.ignore();
+
+ cout << endl << endl;
+
+ cout << "Enter temperature units Celcius or Fahrenheit (C/F): ";
+
+ cin >> letter;
+
+ cout << endl;
+
+
+ }
+
+ if (letter == 'c' || letter == 'C')
+
+ {
+ cout << "Enter the temperature in Celcuius between -62 degrees & 49.5 degrees: ";
+ cin >> T;
+
+ cout << endl;
+
+ //Bounds check
+ while (!((T >= -62) && (T <= 49.5F)))
+
+ {
+ cout << "Temperature lies outside of accepted bounds" << endl;
+
+ cin.clear();
+
+ cin.ignore();
+
+ cout << endl;
+
+ cout << "Enter the temperature in Celcuius between -62 degrees & 49.5 degrees: ";
+
+ cin >> T;
+
+ cout << endl;
+
+
+ }
+ }
+
+ else
+ {
+
+ cout << "Enter the temperature in Fahrtenheit beteen -80 degrees & 121 degrees: ";
+ cin >> t;
+
+ cout << endl;
+
+ //Bounds check
+ while (!((t >= -80) && (t <= 121)))
+ {
+
+ cout << "Temperature lies outside of accepted bounds" << endl;
+
+ cin.clear();
+
+ cin.ignore();
+
+ cout << endl;
+
+ cout << "Enter the temperature in Fahrtenheit beteen -80 degrees & 121 degrees: ";
+
+ cin >> t;
+
+ cout << endl;
+ }
+ }
+
+ cout << "Enter wind speed between 0 MPH & 231 MPH: ";
+ cin >> W;
+
+ cout << endl;
+
+ //Bounds check
+ while (!((W >= 0) && (W <= 231)))
+ {
+
+ cout << "Wind speed lies outside of accepted bounds" << endl;
+
+ cin.clear();
+
+ cin.ignore();
+
+ cout << endl;
+
+ cout << "Enter wind speed between 0 MPH & 231 MPH: ";
+
+ cin >> W;
+
+ cout << endl;
+ }
+}
+
+//Fahrenheit Conversion Function that returns a floating value
+float FahrenheitConversion(float T)
+{
+
+ return (((9.0F / 5) * T) + 32);
+
+}
+//wind chill calculation that returns a floating value
+float WindChillCalculation(int W, float t)
+{
+
+ return (35.74F + 0.6215F * t - 35.75 * (pow(W, 0.16F)) + 0.4275F * t * (pow(W, 0.16F)));
+
+} \ No newline at end of file