Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

why my results can't pass the 999 limit?

 
Or Ben-Moshe
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the problem of this code is that the result won't past the 999 limit.
for example if i put "800 * 5" the result given back is 40 instead of 4000.
what is the problem?
there is the code:

 
Kemal Sokolovic
Bartender
Posts: 825
5
Java Python Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
With

if you enter "800" you're just picking '8', so that's the value you are working with. Rather confusing calculator, I must say... And please UseCodeTags.

Edit: Now I see you edited your post and put your code inside code tags.
 
Or Ben-Moshe
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks but i figured it out alone a few minutes ago
 
Or Ben-Moshe
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
but still i can't figure out how to do it without converting the string to char
 
Or Ben-Moshe
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thats all i got this alone here is the working code
 
Kemal Sokolovic
Bartender
Posts: 825
5
Java Python Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why not extract value of desired type directly from String? Check the API for valueOf(String s) method (depending on type of the value you want to get from string it might be in Integer, Double, ..., class).

Edit: Avoid comparing Strings with '==' oparator. Use equals() instead.
 
Campbell Ritchie
Sheriff
Pie
Posts: 49405
62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And welcome to the Ranch
 
Kemal Sokolovic
Bartender
Posts: 825
5
Java Python Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:And welcome to the Ranch


Hm, I usually forget that part!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic