Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You need to write a program with three functions. Your main function is your first function. In addition to the main function you will need

You need to write a program with three functions. Your main function is your first function.

In addition to the main function you will need a function will take a temperature in Fahrenheit and convert it to Celsius. This function will take one parameter and returns a double. The parameter, passed by value, will be the temperature in Fahrenheit. The function will take the temperature and covert it to Celsius. The Celsius value is returned by the function to the calling program. Call this function convertFromFahrenheit.

The final function will convert Fahrenheit to Celsius and to Kelvin. The function will take three parameters. The first parameter, passed by value, will be the temperature in Fahrenheit. The second parameter, passed by reference, will be the output variable for the temperature in Celsius, and the third parameter, also passed by reference, will be the output variable for the temperature in Kelvin. The function return type will be void. The name of the function

is convertFromFahrenheit.

How can we have two functions named covertFromFahrenheit? We are using function overloading. If convertFromFahrenheit is called with only one parameter the first version of convertFromFahrenheit will be called. If the convertFromFahrenheit function is called with three parameters the second version of convertFromFahrenheit will be called.

You need to do some research to get the conversion formulae for these differing temperature scales.

Both of these conversion functions must have the same name, but they take a different number of parameters. This is an example of an overloaded functions. Only the first version will return back a value with a return statement. For the other version, the converted values are returned back via the variables passed by reference.

Your main function needs to do the following:

Prompt for the user to enter in a temperature in Fahrenheit and read it into a variable.

Call your first function to convert the temperature from Fahrenheit to Celsius.

Display the temperature in Fahrenheit, and Celsius. You can use the abbreviations F, and

C in your output - otherwise you have to spell out Fahrenheit, and Celsius in your output.

Prompt for and read in a second temperature (in Fahrenheit).

Call your second function to convert the temperature to Celsius, and Kelvin.

Display the temperature in Fahrenheit, Celsius, and Kelvin. You can use the

abbreviations F, C, and K in your output otherwise you have to spell out Fahrenheit, Celsius and Kelvin in your output.

If you want to, you can create additional functions for the input and display of the output. You do not need an input loop.

Do not use any global variables. You may want to use const variables, but they should be defined in the functions and should not be global.

Display the output numbers in the format x.xx (2 decimal digits to the right of the decimal point). Here are some sample answers. Your output should NOT be in a table format.

image text in transcribed

For the first value above (-459.67F) you may see a result of -0.00K. This is due to rounding during the conversion process.

Here is a sample run. Your output must have the same information but can be displayed as you see fit (as long as your output has two digits to the right of the decimal point). The input typed in by the application user is in bold.

Enter temperature in Fahrenheit: 104[Enter] Temperature is 104.00F, and 40.00C. Enter temperature in Fahrenheit: 0[Enter] Temperature is 0.00F, -17.78C, and 255.37K.

Your screenshot should be of the above run. You may include other values to illustrate a good job of testing (e.g., -459.67, -470, 32, 212, 500).

Fahrenheit (as entered) Celsius 459.67 104 0 -273.15 40.00 17.78 Kelvin 0.00 313.15 255.37

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

Intelligent Databases Technologies And Applications

Authors: Zongmin Ma

1st Edition

1599041219, 978-1599041216

More Books

Students also viewed these Databases questions

Question

What do Dimensions represent in OLAP Cubes?

Answered: 1 week ago