Lab5 - Temperature Conversion
Write a complete
C++ program that will convert a temperature from Fahrenheit to Celsius or
from Celsius to Fahrenheit, depending on what the user indicates he/she wants.
(Hint: Use nested if-else or a
switch statement).
The user is asked to enter a
temperature value. The user is then
asked if he or she wishes to convert this value to Celsius or Fahrenheit. Your program then prints an appropriate
statement depending on what the user chooses to do.
Use the following formula in
your program:
Fahrenheit
= (9.0/5.0) * Celsius + 32;
Celsius =
(5.0/9.0)*(Fahrenheit - 32);
Write your algorithm, and
hand it in, BEFORE you code your program.
(You still need to code this as a comment at the top of your
program).
Below is a sample output for
your program. You may also organize your
own display, as long as it prints all the necessary information. Make sure to test your program with enough
inputs so that you are sure that all logical paths in your code are working
properly.
Be mindful of the RUBRIC!!
Output
I
Please
enter a temperature: 100
Please
enter an "f" if you wish to convert from Fahrenheit to Celsius
Please
enter a "c" if you wish to convert from Celsius to Fahrenheit
Please
enter any other character to quit: c
Your
temperature in Fahrenheit is: 212
Thank you
for using our temperature conversion program
Press any
key to continue
Output
II
Please
enter a temperature: 212
Please
enter an "f" if you wish to convert from Fahrenheit to Celsius
Please
enter a "c" if you wish to convert from Celsius to Fahrenheit
Please
enter any other character to quit: f
Your
temperature in Celsius is: 100
Thank you
for using our temperature conversion program
Press any
key to continue
Output
III
Please
enter a temperature: 555
Please
enter an "f" if you wish to convert from Fahrenheit to Celsius
Please
enter a "c" if you wish to convert from Celsius to Fahrenheit
Please
enter any other character to quit: w
Thank you
for using our temperature conversion program.
Press any
key to continue