Question: I need the following program to be modified so that the calculations for temperature conversion are done within functions. For this assignment you will need

I need the following program to be modified so that the calculations for temperature conversion are done within functions. For this assignment you will need three separate functions. They are as follows:

C2F - Converts Celsius to Fahrenheit.

K2F - Converts Kelvin to Fahrenheit

N2F - Converts Newtons to Fahrenheit

Each of the above functions should take as an argument a double value which holds the temperature to be converted. These functions should also return a double value which holds the value converted to Fahrenheit. You should only modify the solution for lab 9 to replace the temperature conversion formulas to function calls. Make sure that you name these functions as outlined above. Remember, 35% of your grade is for following the directions.

The following is required for your three functions

Input - Temperature to be converted

Process - Covert value to Fahrenheit using the appropriate equation

Output - Temperature converted to Fahrenheit

#include

using namespace std;

int main()

{

double val;

char type;

cout << "This temperature conversion program converts other temprature types to Fahrenheit";

cout << " The temperature types are:";

cout << " C - Celsius K - Kelvin N - Newton x - eXIT";

cout << " To use the converter you must input a value and one of the temperature types.";

cout << " For example, 32 C converts 32 degrees from Celcius to Fahrenheit";

while ()

{

cout << " Please enter a value and it's type to be converted ";

cin >> num >> type;

switch (type)

{

case 'C':

{ double F;

F = num * 9 / 5 + 32;

cout << " " << num << type << " is " << F << " in Fahrenheit.";

}

break;

case 'K':

{ double F;

F = (num - 273.15) * 1.8 + 32;

cout << " " << num << type << " is " << F << " in Fahrenheit.";

}

break;

case 'N':

{ double F;

F = num * 60 / 11 + 32;

cout << " " << num << type << " is " << F << " in Fahrenheit.";

}

break;

case 'x';

{

return 0;

}

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!