• 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

my last question for this program.

 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

 
Ranch Hand
Posts: 1296
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
What are your superhero powers? Go ahead and try them on this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic