Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Principles Programming And Performance

Authors: Patrick O'Neil

1st Edition

1558603921, 978-1558603929

More Books

Students also viewed these Databases questions

Question

1) What sort of questions would you ask and why?

Answered: 1 week ago