//Temperature scale conversion #include<iostream> using namespace std; int main() { double tin,tout; int choice; char cont; a:cout<<"What do you want to do?\n\n"; //Get the choice of the user cout<<"1.Fahrenheit to Celsius\n2.Celsius to Fahrenheit"<<endl; cout<<"\nEnter either '1' or '2'"<<endl; cin>>choice; if (choice==1) { cout<<"\nEnter the temperature in Fahrenheit"<<endl; //Get the temp in Fahrenheit cin>>tin; tout=(tin-32.0)*5.0/9.0; //Use the conversion Formula cout<<"\nThe temperature in Celsius is "<<tout<<endl; //Print the answer cout<<"\nWant to continue?, Y or N"<<endl; //Ask the user if they want to continue cin>>cont; if (cont=='Y'||cont=='y') goto a; } else if (choice==2) { cout<<"\nEnter the temperature in Celsius"<<endl; //Get the temp in Celsius cin>>tin; tout=9*tin/5+32; //Use the conversion Formula cout<<"The temperature in Fahrenheit is "<<tout<<endl; //Print the answer cout<<"\nWant to continue?, Y or N"<<endl; cin>>cont; if (cont=='Y'||cont=='y') goto a; } else { cout<<"Enter a valid choice"<<endl; goto a; } return 0; }
I’m a physicist specializing in computational material science with a PhD in Physics from Friedrich-Schiller University Jena, Germany. I write efficient codes for simulating light-matter interactions at atomic scales. I like to develop Physics, DFT, and Machine Learning related apps and software from time to time. Can code in most of the popular languages. I like to share my knowledge in Physics and applications using this Blog and a YouTube channel.
[wpedon id="7041" align="center"]