diff options
| author | Taylor Rogers <[email protected]> | 2022-11-08 08:56:40 -0800 |
|---|---|---|
| committer | Taylor Rogers <[email protected]> | 2022-11-08 08:56:40 -0800 |
| commit | 58b632c906a9111bd922c393cf8926078443770a (patch) | |
| tree | 263de780cad8d3dc888050b4d31cffdc344f4931 | |
| parent | Got all the functions sorta working (diff) | |
| download | cst116-lab2-taylorrog-58b632c906a9111bd922c393cf8926078443770a.tar.xz cst116-lab2-taylorrog-58b632c906a9111bd922c393cf8926078443770a.zip | |
Changed how the limits work
| -rw-r--r-- | BlankConsoleLab/BlankConsoleLab.cpp | 89 |
1 files changed, 30 insertions, 59 deletions
diff --git a/BlankConsoleLab/BlankConsoleLab.cpp b/BlankConsoleLab/BlankConsoleLab.cpp index 957cc05..ed2e4c8 100644 --- a/BlankConsoleLab/BlankConsoleLab.cpp +++ b/BlankConsoleLab/BlankConsoleLab.cpp @@ -57,6 +57,7 @@ float TvalC{}; int Wspeed{}; float Wchill{}; + // Converts Fahrenheit to Celsius float FtoCfunc(float FtoCval) { @@ -86,6 +87,7 @@ float Wchfunc(float Wchcalc) return (Wchill); } + int main() { @@ -94,67 +96,47 @@ int main() cin >> Tunit; cout << endl; - cout << "Please enter temperature: "; // Temp input in F if (Tunit == 70) { + + cout << "Please enter temperature between " << Fmin << " and " << Fmax << "degrees F: "; cin >> TvalF; - while (TvalF < Fmin) + if (TvalF > Fmax) { - cout << "Please enter a value greater than " << Fmin << ": "; - cin >> TvalF; - - while (TvalF > Fmax) - { - cout << "Please enter a value less than " << Fmax << ": "; - cin >> TvalF; - } + TvalF = Fmax; + cout << "Value set to " << Fmax << "F." << endl; } - - while (TvalF > Fmax) + else if (TvalF < Fmin) { - cout << "Please enter a value less than " << Fmax << ": "; - cin >> TvalF; - - while (TvalF > Fmin) - { - cout << "Please enter a value greater than " << Fmin << ": "; - cin >> TvalF; - } + TvalF = Fmin; + cout << "Value set to " << Fmin << "F." << endl; } + FtoCfunc(TvalC); } + // Temp input in C else if (Tunit == 67) { + + cout << "Please enter temperature between " << Cmin << " and " << Cmax << "degrees C: "; cin >> TvalC; - while (TvalC < Cmin) + if (TvalC > Cmax) { - cout << "Please enter a value greater than " << Cmin << ": "; - cin >> TvalC; - - while (TvalC > Cmax) - { - cout << "Please enter a value less than " << Cmax << ": "; - cin >> TvalC; - } + TvalC = Cmax; + cout << "Value set to " << Cmax << "C." << endl; } - - while (TvalC > Cmax) + else if (TvalC < Cmin) { - cout << "Please enter a value less than " << Cmax << ": "; - cin >> TvalC; - - while (TvalC > Cmin) - { - cout << "Please enter a value greater than " << Cmin << ": "; - cin >> TvalC; - } + TvalC = Cmin; + cout << "Value set to " << Cmin << "C." << endl; } + CtoFfunc(TvalF); } @@ -163,32 +145,21 @@ int main() //Windspeed - cout << "Please enter the windpeed in Miles Per Hour: "; + cout << "Please enter a windpeed value between 0 and 231 in Miles Per Hour: "; + cin >> Wspeed; - while (Wspeed < Wmin) + if (Wspeed > Wmax) { - cout << "Please enter a value greater than " << Wmin << ": "; - cin >> Wspeed; - - while (Wspeed > Wmax) - { - cout << "Please enter a value less than " << Wmax << ": "; - cin >> Wspeed; - } + Wspeed = Wmax; + cout << "Value set to " << Wmax << "MPH." << endl; } - - while (Wspeed > Wmax) + else if (Wspeed < Wmin) { - cout << "Please enter a value less than " << Wmax << ": "; - cin >> Wspeed; - - while (Wspeed > Wmin) - { - cout << "Please enter a value greater than " << Wmin << ": "; - cin >> Wspeed; - } + Wspeed = Wmin; + cout << "Value set to " << Wmin << "MPH." << endl; } + Wchfunc(Wchill); |