In: Computer Science
Use C++ to create an application that provide the menu with two options
TemperatureConverter_Smith.cpp
MENU CONVERTER TEMPERATURE – JAMES SMITH
CASE 1: Convert Fahrenheit temperature to Celsius
-Display the message to ask to enter Fahrenheit degree from the keyboard
-Use the following formula to convert to Celsius degree
Celsius Temperature = (Fahrenheit Temperature – 32) * 5/9 ;
-Display the output as below:
TemperatureConverter_Smith.cpp
TEMPERATURE CONVERTER – JAMES SMITH
Input temperature in Fahrenheit: 86
Temperature in Celsius: 30
CASE 2: Convert Celsius temperature to Fahrenheit
-Display the message to ask to enter Celsius degree from the keyboard
-Use the following formula to covert to Fahrenheit degree:
Fahrenheit Temperature = 9/5 * Celsius Temperature + 32;
-Display the output as below:
TemperatureConverter_Smith.cpp
TEMPERATURE CONVERTER – JAMES SMITH
Input temperature in Celsius: 30
Temperature in Fahrenheit: 86
Source Code:
Output:
Code in text format (See above images of code for indentation):
#include <iostream>
using namespace std;
/*main function*/
int main()
{
/*variables*/
double f,c,temp;
int opt;
while(1)
{
/*dispaly menu*/
cout<<"\nMENU CONVERTER
TEMPERATURE - JAMES SMITH"<<endl;
cout<<"Convert Fahrenheit
temperature to Celsius"<<endl;
cout<<"Convert Celsius
temperature to Fahrenheit"<<endl;
cout<<"Exit\n"<<"Choose
your option: ";
/*read option from user*/
cin>>opt;
switch(opt)
{
/*case 1
fahrenheit to celsius*/
case 1:
cout<<"TEMPERATURE CONVERTER - JAMES
SMITH"<<endl;
cout<<"Input temperature in
Fahrenheit:\n";
/*read temperature in fahrenheit*/
cin>>f;
/*convert to celsius*/
c=(f-32)*5/9;
cout<<"Temperature in
Celsius:\n"<<c<<endl;
break;
/*case 2 celsius
to fahrenheit*/
case 2:
cout<<"TEMPERATURE CONVERTER - JAMES
SMITH"<<endl;
cout<<"Input temperature in
Celsius:\n";
/*read temperature in celsius*/
cin>>c;
/*convert to Fahrenheit*/
f=(9*c)/5+32.0;
cout<<"Temperature in
Fahrenheit:\n"<<f<<endl;
break;
/*case 3 to
exit*/
case 3:
exit(0);
/*default for
invalid options*/
default:
cout<<"You entered invalid
option!"<<endl;
}
}
return 0;
}