Question: Complete the program using C++, For this program you will code temperature conversions from either Fahrenheit to Celsius or from Celsius to Fahrenheit, and will

Complete the program using C++,

For this program you will code temperature conversions from either Fahrenheit to Celsius or from Celsius to Fahrenheit, and will include the user option to display degrees Kelvin as well.

A sample run of the completed program might be as follows:

Welcome to the Temperature Converter!

Would you like to see degrees Kelvin (K) in the results? (Y/N): Y

Select conversion type (1=F to C, 2=C to F, 0=end): 1

Enter your Fahrenheit temperature: 32

A temp of 32 Fahrenheit converted to Celsius = 0 C.

This is also a temperature of: 273.15 K

Select conversion type (1=F to C, 2=C to F, 0=end): 2

Enter your Celsius temperature: 100

A temp of 100 Celsius converted to Fahrenheit = 212 F.

This is also a temperature of: 373.15 K

Select conversion type (1=F to C, 2=C to F, 0=end): 0

Thanks for using the temperature converter!

The Formulas for the conversion are as follows:

Co = 5/9(Fo - 32)

Fo = (9/5 Co) + 32

Thus, the program sample of converting 32 degrees F to C was: (5/9)*(32-32) = 0.

Likewise, the conversion of 100 degrees C to F was: (9 / 5 * 100) + 32 = 212.

The conversion to degrees K is fairly straightforward; the formulas can be reviewed here: http://en.wikipedia.org/wiki/Kelvin

To accomplish the degrees K option you must store the original user decision (as to whether or not they want to see K), and, if needed, at the end of each conversion function call a different function to produce the additional degrees K output line. Call this method: showDegreesK().

Also, inside the showDegreesK() function write a validation routine which recognizes an illegal temperature and prints an appropriate message. In other words, since the Kelvin scale is based on absolute zero, a negative result for degrees K should be considered illegal, and an error message should be shown instead of the calculated value.

In general you should seek to minimize the amount of code inside the main() function, and separate other processes into their own functions (to adhere to modular principles).

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!