• 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

Loop for console input....

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
All right guys and gals, I've been working on this for hours now, and I am stuck!! I get a user's choice from console, and perform some actions based on that choice. After, they can enter 'y' to try another menu choice, or any key to exit the program. I have gotten to where the program runs great, and when they choose y to try again, the menu will print, and they can do another choice, but if I want to choose 'y' again, it just ends. I would like to get it to loop so if they press 'y' 1000 times after running a choice (as long as it is not the exit choice) it will print the menu again and they can choose another choise. HOW!!! PLEASE EASE MY FRAZZLED MIND!!! ARGGGHHHH!!!

THANK YOU!!!
 
Ranch Hand
Posts: 382
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your if condition where you check if input is y is the problem. The var input is a String; Strings cannot be compared via the == operator. Look at the String documentation in the API to see what method you need to use.
I noticed that you are setting done = true outside the while loop.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic