Instead of using the if/else statement in selecting a converter. I want it to be a SWITCH statement.
Hope you can help me out guys. Very important for my assingment.
Here is my program:
using namespace std;
int select = -1;
while (select ==-1)
cout << "Please select from the following (0 to quit): " << endl;
cout << "1) Fahrenheit-to-Celsius" << endl;
cout << "2) Celsius-to-Fahrenheit" << endl << endl;
cout << "Enter: ";
cin >> select;
if (select == 1)
cout << " Enter temperature in Fahrenheit to convert to degrees Celsius: ";
cin >> ftemp;
ctemp = (ftemp-32) * 5 / 9;
cout << "Equivalent in Celsius is: " << ctemp << endl;
else if (select == 2)
cout <<" Enter temperature in Celsius to convert to degrees Fahrenheit: ";
cin >> ctemp;
ftemp = ctemp*9/5 + 32;
cout << "Equivalent in Fahrenheit is: " << ftemp << endl;
else if (select == 0)
cout << "Valid options 1 or 2." << endl;
select = -1;
Need Help in my C++ Program.
Post a Reply
|Oldest Newest Rating|
Used in many types of software including music players, video games, and many large scale applications.
|Bucky Roberts Administrator|