Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

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.
 
No more fooling around. Read this tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic