- You set
ato a random number between0and5. - You set
bto a random number between0and5 - a - You set
cto a random number between0and5 - a - b - You set
dto5 - 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]