Question
Write a program which converts temperature degrees between Fahrenheit (F) and Celsius (C) in both directions. Formula are: From F to C -- C =
Write a program which converts temperature degrees between Fahrenheit (F) and Celsius (C) in both directions. Formula are:
From F to C -- C = (F - 32) / 1.8 From C to F -- F = 1.8 * C + 32
Your program must do the following.
Name the source file as "Temperature.cpp".
Allow the user to enter either/both scale, and display the equivalent temperature degree in the other scale. For example, if the user enters "16.0 C", your program should output "60.8 F", while if the user enters "56.2 F", your program outputs "13.4 C".
Accept both upper and lower case character for the scale, that is, F or f and C or c.
Display the result with decimal precision 1.
Write the following functions to do some of tasks involved in the program, and main() MUST call those functions appropriately to pull together the whole program.
double toCels(double t ); This function receives a temperature degree (passed in as the parameter t) which is assumed to be in Fahrenheit, and returns the degree which is the equivalent degree in Celsius.
double toFahren(double t);
This function converts a temperature degree (passed in as the parameter t) which is assumed to be in Celsius, and returns the degree which is the equivalent degree in Fahrenheit.
int findScaleCase(char s); This function receives the scale character (e.g. 'F') as the parameter, and returns an integer -- 0 if is 'F' or 'f', or 1 if it is any other character (and treat/pretend it as the case for Celsius) . Then main() receives the returned case integer, and calls the toCels() or toFahren() function to obtain the equivalent temperature degree.
Here are a couple of sample sessions:
*** Welcome to the temperature converter *** Enter a temperature followed by F/f or C/c: 28.7 f ==> Degree in Celsius is -1.8 C *** Thank you for using my converter. See you again soon! ***
*** Welcome to the temperature converter *** Enter a temperature followed by F/f or C/c: 12.3 c ==> Degree in Fahrenheit is 54.1 F *** Thank you for using my converter. See you again soon! ***
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started