File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

default case

 
Marjorie Gyles
Ranch Hand
Posts: 42
Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My driver program asks for the letter to be entered, then asks for number of hours used. Instead of stopping when I enter a D (or other) letter, it continues until I enter the number of hours, then gives me the error message in the default. I don't get what I've done wrong.

Main



 
Greg Charles
Sheriff
Posts: 2984
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your program prompts for and reads both pieces of data, a letter and a number of hours, before calling the method that has that switch statement. If you want it to validate the letter selection before you prompt for hours, then you have to put in code to do that.
 
Daryle Foulke
Greenhorn
Posts: 8
IntelliJ IDE Ubuntu VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could also uppercase you letter character and then in you case statement you only have to check for uppercase letters.
 
Marjorie Gyles
Ranch Hand
Posts: 42
Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Greg Charles wrote:Your program prompts for and reads both pieces of data, a letter and a number of hours, before calling the method that has that switch statement. If you want it to validate the letter selection before you prompt for hours, then you have to put in code to do that.


Duh, why didn't I see that? Thanks! Does this get easier with practice?
 
Greg Charles
Sheriff
Posts: 2984
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome! Yeah, it eventually gets easier. At least you start to know where to look for problems.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic