diff options
| author | Trenton Stark <[email protected]> | 2022-11-05 12:27:37 -0700 |
|---|---|---|
| committer | Trenton Stark <[email protected]> | 2022-11-05 12:27:37 -0700 |
| commit | 37d5a952affd2f3af0826ec674bf5e4265bbfa13 (patch) | |
| tree | cbd4c1d17cee1afab572ae8782792f348fc34ae4 /BlankConsoleLab/cst116-lab2-stark.cpp | |
| parent | Added wind speed input (diff) | |
| download | cst116-lab2-stark-37d5a952affd2f3af0826ec674bf5e4265bbfa13.tar.xz cst116-lab2-stark-37d5a952affd2f3af0826ec674bf5e4265bbfa13.zip | |
Added wind chill calculation.
Diffstat (limited to 'BlankConsoleLab/cst116-lab2-stark.cpp')
| -rw-r--r-- | BlankConsoleLab/cst116-lab2-stark.cpp | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/BlankConsoleLab/cst116-lab2-stark.cpp b/BlankConsoleLab/cst116-lab2-stark.cpp index ea91610..b8383e7 100644 --- a/BlankConsoleLab/cst116-lab2-stark.cpp +++ b/BlankConsoleLab/cst116-lab2-stark.cpp @@ -3,6 +3,7 @@ // Lab 2 #include <iostream> +#include <cmath> using std::cout; using std::cin; @@ -11,20 +12,23 @@ using std::endl; void inputTemp(float& cTemp, float& fTemp); float tempConverter(float temp, bool dirc); void inputWind(float& windS); -float windChillCalc(float windS); +float windChillCalc(float fTemp, float windS); const float fMin = -80, fMax = 121, cMin = -62, cMax = 49.5, wMin = 0, wMax = 231; //Minimum and maximum valid ranges for all user inputs int main() { - float cTemp, fTemp, windS; + float cTemp, fTemp, windS, windC; - cout << "Welcome to Cold Calculator v0.2" << endl; + cout << "Welcome to Cold Calculator v0.3" << endl; inputTemp(cTemp, fTemp); inputWind(windS); + windC = windChillCalc(fTemp, windS); + cout << cTemp << endl; cout << fTemp << endl; cout << windS << endl; + cout << windC << endl; } //Takes either celcius or fahrenheit then converts it to the other and outputs both by reference @@ -90,6 +94,8 @@ void inputWind(float& windS) { } while (windS < 0 || windS > 231); } -float windChillCalc(float windS) { - +float windChillCalc(float fTemp, float windS) { + float windC; + windC = 35.74 + (0.6125 * fTemp) - (35.75 * pow(windS, 0.16)) + (0.4275 * fTemp * pow(windS, 0.16)); + return windC; } |