summaryrefslogtreecommitdiff
path: root/BlankConsoleLab/cst116-lab2-wilson.cpp
diff options
context:
space:
mode:
authorjacobdw22 <[email protected]>2022-11-02 12:59:19 -0700
committerjacobdw22 <[email protected]>2022-11-02 12:59:19 -0700
commitf4255c5923d4d514b01d987b26902ee2c2c52de6 (patch)
treef5600b44aa2979b30cf78c31bf1b001bf8581379 /BlankConsoleLab/cst116-lab2-wilson.cpp
parentRenamed code file to cst116 standard (diff)
downloadcst116-lab2-jacobdw22-f4255c5923d4d514b01d987b26902ee2c2c52de6.tar.xz
cst116-lab2-jacobdw22-f4255c5923d4d514b01d987b26902ee2c2c52de6.zip
Added a windspeed calculator, not yet in a function.
Diffstat (limited to 'BlankConsoleLab/cst116-lab2-wilson.cpp')
-rw-r--r--BlankConsoleLab/cst116-lab2-wilson.cpp20
1 files changed, 18 insertions, 2 deletions
diff --git a/BlankConsoleLab/cst116-lab2-wilson.cpp b/BlankConsoleLab/cst116-lab2-wilson.cpp
index f6e2ee4..03f0859 100644
--- a/BlankConsoleLab/cst116-lab2-wilson.cpp
+++ b/BlankConsoleLab/cst116-lab2-wilson.cpp
@@ -21,7 +21,7 @@ const float CMAX = 49.5;
const float CMIN = -62; //Set values for minimum and maximum temperatures.
-float CtoF(float Fahrenheit, float Celsius) {
+float CtoF(float Fahrenheit, float Celsius) { //float function so that it returns a float
Fahrenheit = (Celsius * 9.0 / 5.0) + 32.0; //Converts Celsius to Fahrenheit
@@ -36,6 +36,7 @@ int main()
{
float Celsius = 0.0; //Defines Celsius for the conversion function
float Fahrenheit = 0.0; //Defines Fahrenheit for the conversion function
+ float windspeed = 0.0;
Loop: //Placeholder to loop back to
@@ -43,11 +44,26 @@ int main()
cin >> Celsius; //Reads in Celsius from the user input
if (Celsius <= CMAX && Celsius >= CMIN) {
- cout << Celsius << " Degrees Celsius is approximately " << CtoF(Fahrenheit, Celsius) << " Degrees Fahrenheit\n\n";
+ cout << "\t" << Celsius << " Degrees Celsius is approximately " << CtoF(Fahrenheit, Celsius) << " Degrees Fahrenheit\n\n";
}
else {
goto Loop; //Goes back to placeholder to Loop in case of invalid response (past limits)
}
+
+ Loop2:
+
+ cout << "Please enter the wind speed between 0 and 231 mph: ";
+ cin >> windspeed;
+
+ if (windspeed <= 231.0 && windspeed >= 0.0) {
+ cout << "\n\tThe temperature is " << CtoF(Fahrenheit, Celsius) << " degrees Fahrenheit and the windspeed is " << windspeed << " mph." << endl;
+ }
+ else {
+ goto Loop2; //Goes back to placeholder to Loop in case of invalid response (past limits)
+ }
+
+
+
}