Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program that will convert: • Degrees Fahrenheit to Degrees Celsius. The

ID: 3641485 • Letter: W

Question

Write a program that will convert:
• Degrees Fahrenheit to Degrees Celsius. The formula is: C = 5/9*(F-32)
• Degrees Celsius to Degrees Fahrenheit. The formula is: F = 9/5 * C + 32
• Degrees Celsius to Degrees Kelvin. The formula is: K = C + 273.15
• Degrees Kelvin to Degrees Celsius. The formula is: C = K – 273.15
Your program needs to display a menu as follows:
1. Fahrenheit 2 Celsius
2. Celsius 2 Fahrenheit
3. Celsius to Kelvin
4. Kelvin to Celsius
5. Exit
If the user enters 5 the program needs to thank the user and terminate. If the user enters any other menu option, then your program needs to gather some data from the user and call the appropriate function. For example, if the user enters 2, then the program needs to prompt the user for the upper range of celsius temperature. You need to capture this information from the user and then call the function celsius2fahrenheit “upper range” number of times (use loop of your choice) passing the loop counter as an argument (celsius) to the function. The function will perform the necessary conversion according to the above converstion table and return the eqivalent of Celsius in Fahrenheit. The program then needs to print the range as a simple table of values (from 1 thorugh the “upper range”)
Your program will need to do the same for any other conversion the user chooses.
You need to write the following functions:
• fahrenheit2Celsius
• celsius2Fahrenheit
• celsius2Kelvin
• kelvin2Celsius
• displayMenu
Use pass by value, pass by reference, and function return types as you see appropriate. You can assume the user will enter positive values for the “upper range”. For the menu choices, you can assume the user will enter integers that may or may not be in the range 1 through 5.

Explanation / Answer

Please rate...

#include<iostream>
#include<stdlib.h>
using namespace std;
double fahrenheit2Celsius(double);
double celsius2Fahrenheit(double);
double celsius2Kelvin(double);
double kelvin2Celsius(double);
int displayMenu();
int main()
{
    int ch;
    while(1)
    {ch=displayMenu();
    switch(ch)
    {
        case 1:
        {
            int a;
            cout<<"Enter the upper range of Fahrenheit temperature: ";
            cin>>a;
            int i;
            double t;
            cout<<" Fahrenheit Celsius";
            cout<<" =========== =========";
            for(i=1;i<=a;i++)
            {
                t=fahrenheit2Celsius((double)i);
                cout<<" "<<i<<" "<<t;
            }
            break;
        }
        case 2:
        {
            int a;
            cout<<"Enter the upper range of Celsius temperature: ";
            cin>>a;
            int i;
            double t;
            cout<<" Celsius Fahrenheit";
            cout<<" =========== =========";
            for(i=1;i<=a;i++)
            {
                t=celsius2Fahrenheit((double)i);
                cout<<" "<<i<<" "<<t;
            }
            break;
        }
        case 3:
        {
            int a;
            cout<<"Enter the upper range of celsius temperature: ";
            cin>>a;
            int i;
            double t;
            cout<<" celsius Kelvin";
            cout<<" =========== =========";
            for(i=1;i<=a;i++)
            {
                t=celsius2Kelvin((double)i);
                cout<<" "<<i<<" "<<t;
            }
            break;
        }
        case 4:
        {
            int a;
            cout<<"Enter the upper range of Kelvin temperature: ";
            cin>>a;
            int i;
            double t;
            cout<<" Kelvin Celsius";
            cout<<" =========== =========";
            for(i=1;i<=a;i++)
            {
                t=kelvin2Celsius((double)i);
                cout<<" "<<i<<" "<<t;
            }
            break;
        }
        case 5:
        {
            exit(1);
        }
        default:
        {
            cout<<" Wrong choice, enter once again: ";
        }
    }
    }
}
int displayMenu()
{
    int ch;
    cout<<" Menu:";
    cout<<" 1. Fahrenheit 2 Celsius";
    cout<<" 2. Celsius 2 Fahrenheit";
    cout<<" 3. Celsius to Kelvin";
    cout<<" 4. Kelvin to Celsius";
    cout<<" 5. Exit";
    cout<<" Enter your choice: ";
    cin>>ch;
    return ch;
}

double fahrenheit2Celsius(double f)
{
    double c;
    c=(5*(f-32))/9;
    return c;
}
double celsius2Fahrenheit(double c)
{
    double f=((9/5) * c) + 32;
    return f;
}
double celsius2Kelvin(double c)
{
    double k=c + 273.15;
    return k;
}
double kelvin2Celsius(double k)
{
    double c=k - 273.15;
    return c;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote