### need help with a kinematics calculator. if & else statements

the objective of my code is to take user input of variables and figure out which equation to use then spit out the appropriate answer to the variable that the user wants to know, what seems to be happening is the acceleration(notibly the first equation function) is steeling the inputs and is kind of ignoring my && constraints. its not a very long program but there is a lot of repetitive code, also i am extremely new to coding so any and all advice is more than appreciated
 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148`` `````` #include using namespace std; #include int keepgoing = true; int main() { while (keepgoing == true) { cout <<"Hi what variable would you like to find"<< endl; cout<<"a = acceleration"<>response; cout <<"if you do not know a variable please put no or n"<>a; if (cin.fail()){ cin.clear(); cin.ignore(999,'\n'); a = (NULL); } cout <<"do you know t = ?"<>t; if (cin.fail()){ cin.clear(); cin.ignore(999,'\n'); t = (NULL); } cout <<"do you know V = ?"<>V; if (cin.fail()){ cin.clear(); cin.ignore(999,'\n'); V = (NULL); } cout <<"do you know Vo = ?"<>Vo; if (cin.fail()){ cin.clear(); cin.ignore(999,'\n'); Vo = (NULL); } cout <<"do you know X = ?"<>X; if (cin.fail()){ cin.clear(); cin.ignore(999,'\n'); X = (NULL); } cout <<"do you know Xo = ?"<>Xo; if (cin.fail()){ cin.clear(); cin.ignore(999,'\n'); Xo = (NULL); } if (response == "a"||"A" && (V!=NULL) &&(Vo!=NULL) && (t!=NULL)) { a = ((V-Vo)/t); cout.precision(5); cout <<"a = ((V-Vo)/t);"<
Last edited on
This is wrong
`if (response == "a"||"A" ... )`

Should look like
`if (response == "a"|| response == "A" ... )`

The first way tries to evaluate "A" , which could turn out to be true since it's non-zero, instead of comparing response to "A"
holy cow i feel really dumb thanks!
Topic archived. No new replies allowed.