Hi guys so I am still learning and there might be an easier way to do thing than how i do them but still i need some help. So I was thinking of making a program in which it asks you a question , lets say Yes/No question and you have to enter the answer.So its should be goood while the person enters Yes or No but I want some way to make the program return to the start of the question if the person just enters something random lets say Potato :D. And my idea was to make a program with Do While and to enter the condition to be something like if X is not Yes/No redo the whole thing , if it is come out of the algorithm and maybe ill add an If to get different answers for yes or no. So how do I do the do while NOT thing and is it even possible. I hope you can understand my logic and thanks in advance :)

Perhaps a switch -- case statement will do the trick here.
case "Yes" do this
case "No" do that
case something else: handle default

So how do I do the do while NOT thing

while(!thing)

Perhaps a switch -- case statement will do the trick here.

You can't switch on strings. And even if you could that would not help with looping.

But can I use other comands after case because the main idea is to make a branching story with choices so in case they chose yes it continues and after that there is another case or something like that?

  1. Convert input to either upper or lower case.
  2. Assuming lower, see if the answer is "yes" or "no".
  3. If neither, then execute the "not a valid answer" branch.
This question has already been answered. Start a new discussion instead.