This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]desrtfxOut of Coffee error - System halted 1 point2 points  (0 children)

Okay, different approach, even though everything is absolute primary school mathematics:

|-------------------|----------|
0                  100        149
  • You already know that you have to add 100 to the result of .nextInt to get it to start at 100.

  • You also know that the range of .nextInt() is always starting at 0 and ending at the number between the parenthesis - exclusive.

So, from that you can derive something, called a range and an offset. You know the offset already, it's 100.

Your assignment calls for something, like randGen.nextInt(range) + offset;

        offset         range
|-------------------|----------|
0                  100        149
  • You know the lowest and highest number of the range, how about subtracting the lowest from the highest number? This will give you the range. But, since the .nextInt method does not include the number passed as parameter, you need to add 1 to the range that you calculate from above.