Computer Science Canada Small Stupid Mistake - Infinite Loop... Help me before i rip my hair out! |
Author: | xtreemboarder [ Wed Jun 13, 2007 5:14 pm ] | ||
Post subject: | Small Stupid Mistake - Infinite Loop... Help me before i rip my hair out! | ||
to sum it up, even though chhh is equal to 'n' or 'y'... it keeps looping. I'm sure a complete noob can find the problem here, i guess im an even bigger noob than a complete noob. |
Author: | HellblazerX [ Wed Jun 13, 2007 6:08 pm ] | ||
Post subject: | Re: Small Stupid Mistake - Infinite Loop... Help me before i rip my hair out! | ||
In your while loop, you keep going as long as the input doesn't match any of these choices, therefore you need it to be and statements (&&) and not or statements (||). |
Author: | HeavenAgain [ Wed Jun 13, 2007 8:14 pm ] |
Post subject: | Re: Small Stupid Mistake - Infinite Loop... Help me before i rip my hair out! |
for a easier understand of the loop, you might want to make a boolean variable and say, if user clicked y or Y then the boolean is true, same geos for n or N and if they clicked other key, then boolean is false and just put it in your do while example: boolean exit = true; do { get the answer if its y or Y then exit = true and edit info if its n or N then exit = true else exit = false "invalid input" } while (!exit); get what i mean? it will be easier to understand how it works when you have a controling variable instead of having a lot of conditions ![]() but of course HellblazerX's method works also |