• 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

Scanner not waiting for input.

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello.

I know this is probably a problem with a stupidly easy fix and I'm just not thinking but I've been trying to figure out why the scanner does not wait for input in this code:



Can anyone help me solve this?

Thanks!
 
Bartender
Posts: 825
5
Python Ruby Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Because you never invoked you MenuInput method inside main, so it doesn't get executed.

Also note that you have two else blocks that contain same statements. Instead of it, you could put if - else if - else blocks to check your input. Or, if you use JDK 7 you can use switch statement with Strings, so it would be the best approach to use here. And, instead of invoking MenuInput again if the user does not provide valid input, you should put everything inside while, that will prompt the user for input until valid one is entered.

Edit: Method names don't start with capital letter in Java.
 
Wilson Cash
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks!
reply
    Bookmark Topic Watch Topic
  • New Topic