diff options
| author | jacobdw22 <[email protected]> | 2022-11-02 01:49:04 -0700 |
|---|---|---|
| committer | jacobdw22 <[email protected]> | 2022-11-02 01:49:04 -0700 |
| commit | 6dd000d0c1a5346eed741dca356ea7507e5567bf (patch) | |
| tree | 3acee1269a5687286a6fb4012be90c3c157e03a4 /BlankConsoleLab/BlankConsoleLab.cpp | |
| parent | Made a Celsius to Fahrenheit converter. (diff) | |
| download | cst116-lab2-jacobdw22-6dd000d0c1a5346eed741dca356ea7507e5567bf.tar.xz cst116-lab2-jacobdw22-6dd000d0c1a5346eed741dca356ea7507e5567bf.zip | |
Now rejects values over or under the limits, and asks for a response again.
Diffstat (limited to 'BlankConsoleLab/BlankConsoleLab.cpp')
| -rw-r--r-- | BlankConsoleLab/BlankConsoleLab.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/BlankConsoleLab/BlankConsoleLab.cpp b/BlankConsoleLab/BlankConsoleLab.cpp index 4b305ff..2252640 100644 --- a/BlankConsoleLab/BlankConsoleLab.cpp +++ b/BlankConsoleLab/BlankConsoleLab.cpp @@ -37,17 +37,17 @@ int main() float Celsius = 0.0; //Defines Celsius for the conversion function float Fahrenheit = 0.0; //Defines Fahrenheit for the conversion function + Loop: - if (Celsius <= 49.5 && Celsius >= -62) { - cout << "Please enter a temperature between -62 and 49.5 degrees Celsius: \n"; - cin >> Celsius; //Reads in Celsius from the user input + cout << "Please enter a temperature between -62 and 49.5 degrees Celsius: \n"; + 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"; } - else{ - cout << "Please enter a temperature between -62 and 49.5 degrees Celsius: \n"; + else { + goto Loop; } - - cout << Celsius << " Degrees Celsius is approximately " << CtoF(Fahrenheit, Celsius) << " Degrees Fahrenheit\n\n"; - } |