• Post Reply Bookmark Topic Watch Topic
  • New Topic

Can someone check for me?  RSS feed

 
Nya Chan
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wrote this program but when i typed in numbers such as 21.9 it returns a rounded number of 21.900000000000002...

so mind explaining why to me?



thanx
[ June 29, 2006: Message edited by: Nya Chan ]
 
Michael Dunn
Ranch Hand
Posts: 4632
 
Nya Chan
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
oh ok thanx.

but is there any ways to make it so it doesn't do that?
 
Keith Lynn
Ranch Hand
Posts: 2409
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use BigDecimal
 
Nya Chan
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what about my question in the code?
when you use readLine (); it reads the whole line right? it there a way to get it to only read what the user inputs?
i tried read(); but it doesn't seem to work for strings
 
Keith Lynn
Ranch Hand
Posts: 2409
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Look at the Scanner class. Scanner was introduced in 1.5 to make reading easier.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!