i suggest changing the else if to just if, i dont think the else if is necessary
and you have to restate what varible you are using
then put just an else as a return to go back to the beginning
int main()
{
int exercise;
loop_begin:
cout << "Please enter and exercise: ";//i also think that you should create options just in case you forget but that just extra
cin << exercise;
if (exercise == "curl" || exercise == "chinup");
{
cout << "biceps. ";//just shorted it doesnt really matter
}
if (exercise == "pushup" || exercise== "press")
{
//blah blah
}
else
{
cout << "I cant understand you."endl;
goto loop_begin;
}
there is a better thing to use than loops though!!
i would try looking into getline, thats what im trying to do, i dont know how to use it yet
look at the conversation "Why is my varible not changing"
thank you very much im trying to do this assignment out of my book that i have to submit and i just have to have the output of
please enter an exercise: _______
This exercise is for your ______
unfortunally i just found out i can't do the loop option it has to be done as written as it is i got the errors with the if statements but its still not accepting the 'pushup' and the 'dead lift'
first thing i would suggest looking at original is to change the last one, a blankspace, i recently found out, messes up the whole thing. whenever possible avoid it, you can once again look at "Why is my varible not changing"
int main()
{
int exercise;
cout << "Please enter an exercise: ";
cin >> exercise;
if( exercise == 'curl' || "chinup");
{
cout << "This exercise is for your biceps. ";
}
elseif(exercise == 'pushup' || "press");
{
cout << "This exercise is for your pecs. ";
}
elseif(exercise == 'row');
{
cout << "This exercise is for your back. ";
}
elseif(exercise == 'dead lift');
{
cout << "This exercise is for your whole body";
}
}
im getting a error
this is the errors
1>e:\cmpsc 101\5c\5c\5c.cpp(11): error C2678: binary '==' : no operator found which takes a left-hand operand of type 'std::string' (or there is no acceptable conversion)
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\exception(470): could be 'bool std::operator ==(const std::_Exception_ptr &,const std::_Exception_ptr &)'
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\exception(475): or 'bool std::operator ==(std::_Null_type,const std::_Exception_ptr &)'
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\exception(481): or 'bool std::operator ==(const std::_Exception_ptr &,std::_Null_type)'
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\system_error(408): or 'bool std::operator ==(const std::error_code &,const std::error_condition &)'
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\system_error(416): or 'bool std::operator ==(const std::error_condition &,const std::error_code &)'
1> while trying to match the argument list '(std::string, int)'
1>e:\cmpsc 101\5c\5c\5c.cpp(12): warning C4390: ';' : empty controlled statement found; is this the intent?
1>e:\cmpsc 101\5c\5c\5c.cpp(15): error C2181: illegal else without matching if
1>e:\cmpsc 101\5c\5c\5c.cpp(15): error C2015: too many characters in constant
1>e:\cmpsc 101\5c\5c\5c.cpp(15): error C2678: binary '==' : no operator found which takes a left-hand operand of type 'std::string' (or there is no acceptable conversion)
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\exception(470): could be 'bool std::operator ==(const std::_Exception_ptr &,const std::_Exception_ptr &)'
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\exception(475): or 'bool std::operator ==(std::_Null_type,const std::_Exception_ptr &)'
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\exception(481): or 'bool std::operator ==(const std::_Exception_ptr &,std::_Null_type)'
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\system_error(408): or 'bool std::operator ==(const std::error_code &,const std::error_condition &)'
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\system_error(416): or 'bool std::operator ==(const std::error_condition &,const std::error_code &)'
1> while trying to match the argument list '(std::string, int)'
1>e:\cmpsc 101\5c\5c\5c.cpp(16): warning C4390: ';' : empty controlled statement found; is this the intent?
1>e:\cmpsc 101\5c\5c\5c.cpp(19): error C2181: illegal else without matching if
1>e:\cmpsc 101\5c\5c\5c.cpp(19): error C2678: binary '==' : no operator found which takes a left-hand operand of type 'std::string' (or there is no acceptable conversion)
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\exception(470): could be 'bool std::operator ==(const std::_Exception_ptr &,const std::_Exception_ptr &)'
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\exception(475): or 'bool std::operator ==(std::_Null_type,const std::_Exception_ptr &)'
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\exception(481): or 'bool std::operator ==(const std::_Exception_ptr &,std::_Null_type)'
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\system_error(408): or 'bool std::operator ==(const std::error_code &,const std::error_condition &)'
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\system_error(416): or 'bool std::operator ==(const std::error_condition &,const std::error_code &)'
1> while trying to match the argument list '(std::string, int)'
1>e:\cmpsc 101\5c\5c\5c.cpp(20): warning C4390: ';' : empty controlled statement found; is this the intent?
1>e:\cmpsc 101\5c\5c\5c.cpp(23): error C2181: illegal else without matching if
1>e:\cmpsc 101\5c\5c\5c.cpp(23): error C2015: too many characters in constant
1>e:\cmpsc 101\5c\5c\5c.cpp(23): error C2678: binary '==' : no operator found which takes a left-hand operand of type 'std::string' (or there is no acceptable conversion)
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\exception(470): could be 'bool std::operator ==(const std::_Exception_ptr &,const std::_Exception_ptr &)'
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\exception(475): or 'bool std::operator ==(std::_Null_type,const std::_Exception_ptr &)'
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\exception(481): or 'bool std::operator ==(const std::_Exception_ptr &,std::_Null_type)'
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\system_error(408): or 'bool std::operator ==(const std::error_code &,const std::error_condition &)'
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\system_error(416): or 'bool std::operator ==(const std::error_condition &,const std::error_code &)'
1> while trying to match the argument list '(std::string, int)'
1>e:\cmpsc 101\5c\5c\5c.cpp(24): warning C4390: ';' : empty controlled statement found; is this the intent?