Thread: java help
View Single Post
 
Reply
Posted 2009-05-11, 08:26 AM in reply to osmoses-jones's post "java help"
I can't see anything that would give you a problem if your input is right - that is, if the user enters a number. If they enter a letter or any other character, however, then you'll get a NumberFormatException. What's the error that you keep on getting (and which line?)? Btw, which program are you using to program in?

Have you done anything about exceptions, and using Try and Catch yet, or anything about defensive programming?

EDIT: If you've not done exceptions and try/catch, then I won't bother giving you an answer with them - it'll just serve to confuse you until you learn about them.

I got a happy feeling inside when I saw the code, by the way - that's one of the first things I was taught when I was learning VB.

Oh, and what SYG suggests will make your code look prettier, but not much else (which isn't a bad thing - pretty code is always much easier to read than unpretty code).

Last edited by Lenny; 2009-05-11 at 08:34 AM.
Old
Profile PM WWW Search
Lenny simplifies with no grasp of the basicsLenny simplifies with no grasp of the basicsLenny simplifies with no grasp of the basicsLenny simplifies with no grasp of the basicsLenny simplifies with no grasp of the basicsLenny simplifies with no grasp of the basics
 
 
Lenny