diff options
| author | jacobdw22 <[email protected]> | 2022-11-02 13:08:41 -0700 |
|---|---|---|
| committer | jacobdw22 <[email protected]> | 2022-11-02 13:08:41 -0700 |
| commit | 0e69f10d12f4292cae3c53edd1cbb5c6b43bc734 (patch) | |
| tree | 09d4764177ad4a999a69ffe61607e21ae625b3a8 | |
| parent | Added a windspeed calculator, not yet in a function. (diff) | |
| download | cst116-lab2-jacobdw22-0e69f10d12f4292cae3c53edd1cbb5c6b43bc734.tar.xz cst116-lab2-jacobdw22-0e69f10d12f4292cae3c53edd1cbb5c6b43bc734.zip | |
Finsihed WindSpeedFinder function
| -rw-r--r-- | BlankConsoleLab/cst116-lab2-wilson.cpp | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/BlankConsoleLab/cst116-lab2-wilson.cpp b/BlankConsoleLab/cst116-lab2-wilson.cpp index 03f0859..a8e2729 100644 --- a/BlankConsoleLab/cst116-lab2-wilson.cpp +++ b/BlankConsoleLab/cst116-lab2-wilson.cpp @@ -29,14 +29,28 @@ float CtoF(float Fahrenheit, float Celsius) { //float function so that it return } +void WindSpeedFinder(int* windspeed) { //Float function to return float value +Loop2: + + cout << "Please enter the wind speed between 0 and 231 mph: "; + cin >> *windspeed; + + if (*windspeed <= 231 && *windspeed >= 0) { + cout << "\n\tThe windspeed is " << *windspeed << " mph." << endl; + } + else { + goto Loop2; //Goes back to placeholder to Loop in case of invalid response (past limits) + } + +} 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; + int windspeed = 0; Loop: //Placeholder to loop back to @@ -51,19 +65,7 @@ int main() } - 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) - } - - + WindSpeedFinder(&windspeed); } |