Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Students also viewed these Databases questions

Question

1. Identify three approaches to culture.

Answered: 1 week ago

Question

3. Identify and describe nine cultural value orientations.

Answered: 1 week ago

Question

4. Describe how cultural values influence communication.

Answered: 1 week ago