aspose file tools*
The moose likes Beginning Java and the fly likes my last question for this program. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "my last question for this program." Watch "my last question for this program." New topic
Author

my last question for this program.

ken zemaitis
Ranch Hand

Joined: Sep 26, 2005
Posts: 42
Hello again everyone. Your help has been appreciated beyond belief. I have finally gotten this program straightened out, however, I am having one last problem. All of the calculations are correct, and it runs smoothly, except when I try to enter a tax rate at the same time I begin running the program.
When I enter "C:\Temp>java Project02 .04," after the program compiles, the .04 is supposed to be the tax rate that the program uses. When I don't enter the ".04" the program works perfectly, however, when I enter that extra data that the program is supposed to recognize, it tells me the following:

"Exception in thread "main" java.lang.NumberFormatException: For input string: ".04" at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48) at java.lang.Integer.parseInt(Integer.java.:468) at java.lang.Integer.parseInt(Integer.java:518) at Project02.main(Project02.java:38)

I placed "**********" in the code again to denote where I think the problem may lie, is that not the statement that is supposed to accept the ".04" or whatever value I enter?

I am very confused as to what I should do, and I have read over the exceptions. Can anyone give me any advice? Thanks a lot...again.

Garrett Rowe
Ranch Hand

Joined: Jan 17, 2006
Posts: 1296
You need to replace Integer.parseInt() with Double.parseDouble().


Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them. - Laurence J. Peter
ken zemaitis
Ranch Hand

Joined: Sep 26, 2005
Posts: 42
Originally posted by Garrett Rowe:
You need to replace Integer.parseInt() with Double.parseDouble().


I replaced the wrong parseInt, which is why I could never get it working. Thank you very much.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: my last question for this program.