2

I know how to do it between 0 and 100, but I can I set the floor?

This is how I do 0 - 100..

int randomNum = (int) Math.ceil(Math.random() * 100);
Tom
  • 15,798
  • 4
  • 37
  • 48
Sapp
  • 1,793
  • 7
  • 29
  • 51

5 Answers5

12

Generate a random number from 0 to 25 and add 75. :)

hobbs
  • 223,387
  • 19
  • 210
  • 288
6
int randomNum = (int) Math.ceil(Math.random() * 25) + 75;
Serplat
  • 4,367
  • 2
  • 18
  • 20
4

Generate a number between 0 and 25 and then add 75.

Nathan S.
  • 5,244
  • 3
  • 45
  • 55
3

Do it between zero and 25 and add 75.

NRaf
  • 7,407
  • 13
  • 52
  • 91
3

I know this is answered already but correct answer did not have code snippet. So here is a little code snippet:

int randomNum = 0;
Random ran = new Random();
randomNum  = ran.nextInt(25) + 75;
JPM
  • 9,077
  • 13
  • 78
  • 137