diff options
| -rw-r--r-- | BlankConsoleLab/BlankConsoleLab.cpp | 119 |
1 files changed, 54 insertions, 65 deletions
diff --git a/BlankConsoleLab/BlankConsoleLab.cpp b/BlankConsoleLab/BlankConsoleLab.cpp index 731949a..c03e657 100644 --- a/BlankConsoleLab/BlankConsoleLab.cpp +++ b/BlankConsoleLab/BlankConsoleLab.cpp @@ -63,97 +63,86 @@ float Wchfunc(float& Wchcalc) int main() { + char continu = 'Y'; - // Temp unit selection - cout << "Please enter F for Fahrenheit or C for Celsius: "; - cin >> Tunit; - cout << endl; - - - // Temp input in F - if (Tunit == 70) + while (continu == 'Y') { - cout << "Please enter temperature between " << Fmin << " and " << Fmax << " degrees F: "; - cin >> TvalF; - + // Temp unit selection + cout << "Please enter F for Fahrenheit or C for Celsius: "; + cin >> Tunit; cout << endl; - if (TvalF > Fmax) - { - TvalF = Fmax; - cout << "Value set to " << Fmax << "F." << endl; - cout << endl; - } - else if (TvalF < Fmin) + + // Temp input in F + if (Tunit == 70 || Tunit == 102) { - TvalF = Fmin; - cout << "Value set to " << Fmin << "F." << endl; - cout << endl; - } - FtoCfunc(TvalC); - } + cout << "Please enter temperature between " << Fmin << " and " << Fmax << " degrees F: "; + cin >> TvalF; + cout << endl; - // Temp input in C - else if (Tunit == 67) - { + while (TvalF < Fmin || TvalF > Fmax) + { + cout << "Please enter a value between " << Fmin << " and " << Fmax << ": "; + cin >> TvalF; + } - cout << "Please enter temperature between " << Cmin << " and " << Cmax << " degrees C: "; - cin >> TvalC; - - cout << endl; + FtoCfunc(TvalC); + } - if (TvalC > Cmax) + + // Temp input in C + else if (Tunit == 67 || Tunit == 99) { - TvalC = Cmax; - cout << "Value set to " << Cmax << "C." << endl; + + cout << "Please enter temperature between " << Cmin << " and " << Cmax << " degrees C: "; + cin >> TvalC; + cout << endl; + + while (TvalC < Cmin || TvalC > Cmax) + { + cout << "Please enter a value between " << Cmin << " and " << Cmax << ": "; + cin >> TvalC; + } + + CtoFfunc(TvalF); } - else if (TvalC < Cmin) + + + else { - TvalC = Cmin; - cout << "Value set to " << Cmin << "C." << endl; - cout << endl; + cout << "Invalid unit" << endl; + return 0; } - CtoFfunc(TvalF); - } + //Windspeed + cout << "Please enter a windpeed value between 0 and 231 in Miles Per Hour: "; - else - cout << "Invalid unit" << endl; + cin >> Wspeed; + cout << endl; - //Windspeed - cout << "Please enter a windpeed value between 0 and 231 in Miles Per Hour: "; + while (Wspeed < Wmin || Wspeed > Wmax) + { + cout << "Please enter a value between " << Wmin << " and " << Wmax << ": "; + cin >> Wspeed; + } - cin >> Wspeed; - cout << endl; + Wchfunc(Wchill); - if (Wspeed > Wmax) - { - Wspeed = Wmax; - cout << "Value set to " << Wmax << "MPH." << endl; cout << endl; - } - else if (Wspeed < Wmin) - { - Wspeed = Wmin; - cout << "Value set to " << Wmin << "MPH." << endl; - cout << endl; - } - - Wchfunc(Wchill); + cout << setw(25) << "Temp (C)" << setw(25) << "Temp (F)" << setw(25) << "Wind Speed (MPH)" << setw(25) << "Wind Chill" << endl; - cout << endl; + cout << setw(25) << TvalC << setw(25) << TvalF << setw(25) << Wspeed << setw(25) << Wchill << endl; - cout << setw(25) << "Temp (C)" << setw(25) << "Temp (F)" << setw(25) << "Wind Speed (MPH)" << setw(25) << "Wind Chill" << endl; - - cout << setw(25) << TvalC << setw(25) << TvalF << setw(25) << Wspeed << setw(25) << Wchill << endl; - - cout << endl; + cout << endl; + cout << "Want to do again? Type \'Y\': "; + cin >> continu; + } }
\ No newline at end of file |