I'm trying to write a program that converts Celsius to Fahrenheit and the reverse. I just started learning C++ so this might not be the most efficient way to write this. I'm experiencing errors at the "else if" and "while" parts (line 24 and 32). Any tips?
Code:
Code:#include <iostream> #include <cmath> using namespace std; int whichconversion; char continue_ques; double Fahrenheit; double Celsius; double newFtemp; double newCtemp; void FtoC(double n); void CtoF(double n); int main() { do { cout << "Choose what you would like to : " << endl; cout << "1) Convert F to C" << endl; cout << "2) Convert C to F" << endl; cin >> whichconversion; if( whichconversion == 1 ); { cout << "Enter the F temp you want to convert: " << endl; cin >> Fahrenheit; FtoC(Fahrenheit); }else if( whichconversion == 2); { cout << "Enter the C temp you want to convert: " << endl; cin >> Celsius; CtoF(Celsius); } cout << "Would you like to conduct another conversion? (Yes/No)" << endl; cin >> continue_ques; } while ( continue_ques == Yes ); } void FtoC(double n){ newCtemp = 0.555555555555556*Fahrenheit-32.0 cout << Fahrenheit << "Fahrenheit is equal to " << newCtemp << "Celsius" << endl; } void CtoF(double n){ newFtemp = 1.8*(Celsius+32.0) cout << Celsius << "Celsius is equal to " << newFtemp << "Fahrenheit" << endl; }



LinkBack URL
About LinkBacks



