Need an important loop for my project.
Hey,
I have a school assignment to do on eclipse over the summer months.I am trying to make a vending machine.I want a piece of coding that will loop back to the beginning if the person selects an invalid item.In other words I mean that there are 5 selections and if he presses >5 it would say "Illegal Entry" and start the program again at the welcome screen.
Help would be greatly appreciated as I didn't find anything on Google about it.
P.S I am using Eclipse Juno.
Thank you. :frusty:
Re: Need help with my Eclipse project.PLZ HELP!!
Basically your problem has nothing to do with Eclipse (it is innocent as always). Think of a do { ... } while loop that terminates when the number input by the user is in the wanted interval. It doesn't hurt to craft a little method for this purpose that returns the wanted number; creating separate little methods reduces the complexity of the control flow so you won't end up with wall paper of if-s and while-s and complicated spaghetti code.
kind regards,
Jos
Re: Need help with my Eclipse project.PLZ HELP!!
Thank you for you help.:)-:
Re: Need help with my Eclipse project.PLZ HELP!!
I used to do it on pascal.But on java it's a bit tricky.
Re: Need an important loop for my project.
Re: Need an important loop for my project.
Re: Need help with my Eclipse project.PLZ HELP!!
Quote:
Originally Posted by
Nixter1997
I used to do it on pascal.But on java it's a bit tricky.
OK, it may be over 25 years since I did Pascal, but the logic and flow is not significantly different.
Re: Need an important loop for my project.
Please do not PM for a solution.
If you have something to add then it goes here in the thread.