This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

my last question for this program.

 
ken zemaitis
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1296
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to replace Integer.parseInt() with Double.parseDouble().
 
ken zemaitis
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic