summaryrefslogtreecommitdiff
path: root/BlankConsoleLab/BlankConsoleLab.cpp
diff options
context:
space:
mode:
authorJonCr <[email protected]>2022-11-09 23:37:38 -0800
committerJonCr <[email protected]>2022-11-09 23:37:38 -0800
commitea9e6fcbd144decc9e3ca512141acf1980c56937 (patch)
tree264190e947be85f2cbd1a660a59ea5aac9de2c86 /BlankConsoleLab/BlankConsoleLab.cpp
parentSetting up GitHub Classroom Feedback (diff)
downloadcst116-lab2-cognitiveshadow-ea9e6fcbd144decc9e3ca512141acf1980c56937.tar.xz
cst116-lab2-cognitiveshadow-ea9e6fcbd144decc9e3ca512141acf1980c56937.zip
Update
Diffstat (limited to 'BlankConsoleLab/BlankConsoleLab.cpp')
-rw-r--r--BlankConsoleLab/BlankConsoleLab.cpp98
1 files changed, 97 insertions, 1 deletions
diff --git a/BlankConsoleLab/BlankConsoleLab.cpp b/BlankConsoleLab/BlankConsoleLab.cpp
index ed5f807..f56dfa2 100644
--- a/BlankConsoleLab/BlankConsoleLab.cpp
+++ b/BlankConsoleLab/BlankConsoleLab.cpp
@@ -9,8 +9,104 @@ using std::cout;
using std::cin;
using std::endl;
+int selectType();
+float getTemp(int& select);
+float calcTemp(float& temp);
+float getWindSpeed();
+void calcWindChill(float temp, float windSpeed);
+
int main()
{
- cout << "Hello World!\n";
+ float temp;
+ int select = 0;
+ float windSpeed = 0;
+
+ select = selectType();
+ temp = getTemp(select);
+ if (select == 2)
+ temp = calcTemp(temp);
+ windSpeed = getWindSpeed();
+
+ calcWindChill(temp, windSpeed);
+
+ return 0;
+}
+int selectType()
+{
+ char choose = '0';
+ int select = 0;
+
+ while (select != 1 && select != 2)
+ {
+ cout << "Enter temperature in Fahrenheit or Celsius?" << endl << "[1] Fahrenheit" << endl << "[2] Celsius" << endl;
+ cout << "Selection: ";
+ cin >> choose;
+
+ if (choose == '1')
+ select = 1;
+ else if (choose == '2')
+ select = 2;
+ else cout << "Please enter only 1 or 2." << endl;
+ }
+
+ return select;
}
+float getTemp(int& select)
+{
+ float temp = 0;
+ const int minC = -62;
+ const int maxC = 49.5;
+ const int minF = -80;
+ const int maxF = 121;
+
+ if (select == 1)
+ {
+ while (temp >= minC && temp <= maxC)
+ {
+ cout << endl << "Enter temperature: ";
+ cin >> temp;
+
+ if (temp < minC || temp > maxC)
+ cout << endl << "Please enter between " << minC << " and " << maxC << endl;
+ }
+ }
+
+ if (select == 2)
+ {
+ while (temp >= minF && temp <= maxF)
+ {
+ cout << endl << "Enter temperature: ";
+ cin >> temp;
+
+ if (temp < minF || temp > maxF)
+ cout << endl << "Please enter between " << minF << " and " << maxF << endl;
+ }
+ }
+ return temp;
+}
+float calcTemp(float& Celsius)
+{
+ float Fahrenheit = 0;
+
+ Fahrenheit = (9 / 5) * Celsius + 32;
+
+ return Fahrenheit;
+}
+float getWindSpeed()
+{
+ float windSpeed = 0;
+
+ cout << endl << "Enter wind speed in MPH: ";
+ cin >> windSpeed;
+
+ return windSpeed;
+}
+void calcWindChill(float temp, float windSpeed)
+{
+ double windChill = 0;
+
+ windChill = 35.74 + 0.6215 * temp - 35.75 * windSpeed ^ 0.16 + 0.4275 * temp * windSpeed ^ 0.16;
+
+ cout << endl << windChill;
+}