If I type y or n it stays in the loop. It won't continue. I think it should but if I write it like while (userInput != "y") I can press y and the program goes on.
Truth table for:
while (userInput != "y" || userInput != "n")
user | result | Stay in while loop?
"y" | 1 | yes since userInput != "y" OR userInput != "n""n" | 1 | yes since userInput != "y" OR userInput != "n"
anything else | 1 |yes since "anything else" is not "y" OR "n"
I know that a while loops until the statement is false. So != "y" is true until you type "y" then its false. My problem is the || operator. It made it loop no matter what the input is.