diff options
Diffstat (limited to 'BlankConsoleLab/BlankConsoleLab.cpp')
| -rw-r--r-- | BlankConsoleLab/BlankConsoleLab.cpp | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/BlankConsoleLab/BlankConsoleLab.cpp b/BlankConsoleLab/BlankConsoleLab.cpp index f3e4834..4b305ff 100644 --- a/BlankConsoleLab/BlankConsoleLab.cpp +++ b/BlankConsoleLab/BlankConsoleLab.cpp @@ -24,20 +24,30 @@ const float CMIN = -62; //Set values for minimum and maximum temperatures. -int CtoF(int Celsius) { - return Celsius; +float CtoF(float Fahrenheit, float Celsius) { + + Fahrenheit = (Celsius * 9.0 / 5.0) + 32.0; //Converts Celsius to Fahrenheit + + return Fahrenheit; //Returns the newly defined fahrenheit to main } int main() { - int Celsius = 0; + float Celsius = 0.0; //Defines Celsius for the conversion function + float Fahrenheit = 0.0; //Defines Fahrenheit for the conversion function + + + 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 + } + else{ + cout << "Please enter a temperature between -62 and 49.5 degrees Celsius: \n"; + } - cout << "Please enter a temperature between -62 and 49.5 degrees Celsius: \n"; - cin >> Celsius; - cout << CtoF(12) << endl; + cout << Celsius << " Degrees Celsius is approximately " << CtoF(Fahrenheit, Celsius) << " Degrees Fahrenheit\n\n"; - cout << "Hello World!\n"; } |