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 :)
Kris_3 0
Newbie Poster
Recommended Answers
Jump to PostPerhaps a switch -- case statement will do the trick here.
case "Yes" do this
case "No" do that
case something else: handle default
Jump to PostSo 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.
All 5 Replies
ddanbe 2,724
Professional Procrastinator Featured Poster
sepp2k 378
Practically a Master Poster
Kris_3 0
Newbie Poster
rubberman 1,355
Nearly a Posting Virtuoso Featured Poster
Kris_3 0
Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.