summaryrefslogtreecommitdiff
path: root/BlankConsoleLab/BlankConsoleLab.cpp
diff options
context:
space:
mode:
authorDoolyBoi <[email protected]>2022-11-09 21:00:29 -0800
committerDoolyBoi <[email protected]>2022-11-09 21:00:29 -0800
commita6845f309d811ced3669af714c2aaead95f3e756 (patch)
tree3f69b99b4b85cc5269239e8906820f912ca92f36 /BlankConsoleLab/BlankConsoleLab.cpp
parentadded 3 functions (diff)
downloadcst116-lab2-abd00l4h-a6845f309d811ced3669af714c2aaead95f3e756.tar.xz
cst116-lab2-abd00l4h-a6845f309d811ced3669af714c2aaead95f3e756.zip
made function work
Diffstat (limited to 'BlankConsoleLab/BlankConsoleLab.cpp')
-rw-r--r--BlankConsoleLab/BlankConsoleLab.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/BlankConsoleLab/BlankConsoleLab.cpp b/BlankConsoleLab/BlankConsoleLab.cpp
index 82c5124..3acc188 100644
--- a/BlankConsoleLab/BlankConsoleLab.cpp
+++ b/BlankConsoleLab/BlankConsoleLab.cpp
@@ -10,13 +10,17 @@ void getUserInputs(float& value, float min, float max, string type);
float calculate(float mph, float degrees);
//m is min; M is max
+//Fahrenheit Constants
const float Fm = -80;
const float FM = 121;
+//Celcius Constants
const float Cm = -62;
const float CM = 49.5;
+//Wind Speed Constants
const float Wm = 0;
const float WM = 231;
+//Takes celcius and converts it to fahrenhiet
float C_to_F(float x)
{
x *= 1.8;
@@ -24,16 +28,18 @@ float C_to_F(float x)
return x;
}
+//Asks user for the "value" of "type" which has to be between "min" and "max"
void getUserInputs(float& value, float min, float max, string type)
{
while (value <= min || value >= max)
{
cout << "What is the value of " << type << "?" << endl;
- cout << "(Enter a value between " << Fm << " & " << FM << ")" << endl;
+ cout << "(Enter a value between " << min << " & " << max << ")" << endl;
cin >> value;
}
}
+//calculates the wind chill and returns it
float calculate(float mph, float degrees)
{
return (35.74 + (0.6215 * degrees) - (35.75 * pow(mph, 0.16)) + (0.4275 * degrees * pow(mph, 0.16)));
@@ -44,6 +50,7 @@ int main()
string CorF;
float temp;
float wSpeed;
+ float windChill;
while (CorF != "C" && CorF != "F")
{
@@ -64,6 +71,8 @@ int main()
getUserInputs(wSpeed, Wm, WM, "Wind Speed");
+ windChill = calculate(wSpeed, temp);
+ cout << "At " << temp << "degrees Fahrenheit and at a wind speed of " << wSpeed << "MPH, the windchill is " << windChill << ".";
}