Answer to Question #16506 in C++ for zaima

Question #16506
write a program which displays a menu for temperature conversion; user will choose an option from the menu and program converts temperature for selected option. (use temperature conversion formula C/5=F-32/9=R/4) SAMPLE OUTPUT: 1. Celsius to Fahrenheit 2. Fahrenheit to Celsius 3. Celsius to Reaumur 4. Reaumur to Celsius
1
Expert's answer
2012-10-18T11:01:05-0400
#include "iostream"
using namespace std;

char s1, s2;
float t, T;

void main(){
cout<<"enter \"c\" for Celsius, \"f\" for Fahrenheit, \"r\" for Reaumur: ";
cin>>s1;
cout<<"enter the temparature value: ";
cin>>t;
cout<<"enter the system you want convert to (\"c\" for Celsius, \"f\" for Fahrenheit, \"r\" for Reaumur): ";
cin>>s2;
if (s1==s2) T=t;
if ((s1=='c')&&(s2=='f')) T = 9*t/5+32;
if ((s1=='c')&&(s2=='r')) T = 4*t/5;
if ((s1=='f')&&(s2=='c')) T = 5*(t-32)/9;
if ((s1=='f')&&(s2=='r')) T = 4*(t-32)/9;
if ((s1=='r')&&(s2=='c')) T = 5*t/4;
if ((s1=='r')&&(s2=='f')) T = 9*t/4+32;
cout<<t<<s1<<" = "<<T<<s2<<"\n";
system("pause");
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS
paypal