Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Generating random numbers

 
David JonesK
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi, i'm really stuck, can anyone tell me how to generate random numbers between 100 and 200 in java.
thank you
 
john smith
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This would do it:
 
Vicken Karaoghlanian
Ranch Hand
Posts: 522
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to add one more thing...
Although John's code is correct, 200 is never reached, the closest number you will get is 199.999...
 
David JonesK
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks
 
john smith
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Fair point Vicken - I hadn't noticed that.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic