d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > While Loops + Switch Statements
Prev12
Add Reply New Topic New Poll
Member
Posts: 534
Joined: Feb 8 2011
Gold: 53.30
Feb 23 2013 12:05am
Quote (carteblanche @ Feb 23 2013 12:04am)
oh. i thought you had a problem with the switch/case itself.

uc = input.next();

then make sure your switch is inside the loop so that it goes back to the switch at the next iteration


Is this for the if / else statement, or for a while loop.. I have tried this before and it did not work.. And what do you mean by making sure the switch is inside the loop? recalling the whole: switch (uc) { ??

/e This is what I currently have when doing what you say, but without having the switch inside the loop. Not quite sure what you meant.




This post was edited by Malexir on Feb 23 2013 12:09am
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
Feb 23 2013 12:10am
control flow, bro.

code inside a method executes from top to bottom. so if you want to get back up, you only have a few choices. print out your code on paper trace it out with a pencil if you have to.
Member
Posts: 534
Joined: Feb 8 2011
Gold: 53.30
Feb 23 2013 12:19am
Quote (carteblanche @ Feb 23 2013 12:10am)
control flow, bro.

code inside a method executes from top to bottom. so if you want to get back up, you only have a few choices. print out your code on paper trace it out with a pencil if you have to.


Well for the sake of completion I just removed the user's input and put a break; which results in the user getting the beginning menu choices again. Its a half-ass job but it fits the instruction.. However I still want to learn how to do what I was wanting to previously do.
When you say I only have a few choices to get back up the code, what do you mean exactly. I do not have much knowledge regarding this. And what knowledge I do have, is not very clear. I have had many questions during this code that turned out to be very silly simple mistakes, that I knew how to do, but overlooked.. I have a feeling I am doing the same here.

This post was edited by Malexir on Feb 23 2013 12:19am
Go Back To Programming & Development Topic List
Prev12
Add Reply New Topic New Poll