[Solved] How to hand out a number randomly between variables in Java? [closed]


  1. You set a to a random number between 0 and 5.
  2. You set b to a random number between 0 and 5 - a
  3. You set c to a random number between 0 and 5 - a - b
  4. You set d to 5 - a - b - c

As a result, you get 4 numbers with a sum of 5.

So as not to be boring and repeat tons of questions on Stack Overflow about finding a number in a given range, which would be a sub-task there, here’s a link: How do I generate random integers within a specific range in Java?

1

solved How to hand out a number randomly between variables in Java? [closed]