• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Hi guys I have a school project can you help me out how to go back from previous segment of my code.

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
 
Bartender
Posts: 3648
16
Android Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch.

When you say add another item to salesman, do you mean where xxx is new:


or

have a new Item say


 
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Gia Mata wrote:...
////What should I put here guys??? I wanna go back to the previous menu wherein I R means return to add more items to selected salesperson.


First: Welcome to JavaRanch, Gia.

Second: Please read the UseCodeTags (←click) page; especially the bit about long lines. I actually tried putting code tags in for you, but your lines are so long (and your indenting is also bad) that it actually made the thread harder to read than before.

[Edit: I notice that Ulf's done it for you anyway; but do you see that it now doesn't fit on the screen? That's because your lines are too long.
You can edit your post via the 'Edit' button to break them up if you want.]

Third: To answer your actual question: Put all that code inside a larger loop which you don't break out of until the user enters something that causes you to quit.
Unfortunately, what you'll then end up with is a gigantic block of hellishly indented code; so an alternative is to take most of that "inputting" stuff out of main() and put it in a separate method, then call that method from a loop.

But even better still is probably to StopCoding (←click) and write down what you need to do in English (or your native language) before you write anything else in Java.

It looks to me like you just started coding and have now run into a roadblock, and that's not usually a good way to work.

You may also find the UserInput page worth reading, because user input is notoriously difficult to get right the first time you try it.

HIH

Winston
 
Sheriff
Posts: 7125
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When you stop coding and write down what you want to do, you may get something like: display menu, get user input, act on input, etc. These often translate into separate methods or even classes. Try separating your functions into methods and see if that helps.
 
Ranch Hand
Posts: 355
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It isn't also advisable to use continue; inside your while loop. What do you want to achieve with that?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic