• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to generate a random value about a value! Enjoy  RSS feed

 
Avin Sinanan
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, I posted a question ealier about how to generate a random value about a number. Well someone gave me some advice. SO here it is folks.
Enjoy.
use :
import java.util.Random;
int value= (int) ((new Random().nextGaussian()*20)+100 );
this code will generate values about 100 plus or minus 20.
Hence values will range from 80 to 120.
And it will do so randomly. This code can be very useful.
Hope you all find an opportunity to use it.
yours respectfully Avin Sinanan
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!