HELP. Random Number Between

Hi my current code is

Code java:

int randomNumber = random.nextInt(899) + 100;

My teacher said: Also, the formula for the random number will yield a number in the range of

100 to 998 vs. 100 to 999. (off-by-one error).

So I need to make it so it puts it between 100 - 999. But, I'm confused on how that works exactly.

Re: HELP. Random Number Between

Break apart the equation and have a look at the API for the Random.nextInt function you use - it returns a value between (and including) 0 and the parameter value (excluding that value). So, doing the math, how would you change this beginning part of the equation to return what you want?

Re: HELP. Random Number Between

Quote:

Originally Posted by

**copeg**
Break apart the equation and have a look at the API for the Random.nextInt function you use - it returns a value between (and including) 0 and the parameter value (excluding that value). So, doing the math, how would you change this beginning part of the equation to return what you want?

Remove the next part?

Re: HELP. Random Number Between

Quote:

Originally Posted by

**Raymond Pittman**
Remove the next part?

I'm not sure what this means....but if you have a function that you feed a number N and it returns a value between and including 0-N, how would you get it to return a value between 0-(N+1)?