mardi 16 avril 2019

Is there a random number generator with splitting and limits?

I am looking to create some code. Which will consist of a number input, which will randomly split into 4 different places, each place has a limit which it cannot exceed. I would like to use decimals, but using an int and then adding a decimal later just for presentation will also work in my case. I will give an example here.

Input 4920

1 cannot exceed 6500,
2 cannot exceed 1700,
3 cannot exceed 9000,
4 cannot exceed 1700

But each time i need where the numbers go to be completely random, so each place returns a different number each time while none exceed their limits. They can equal to their limits, but i would like the numbers not to be at their maximums all the time, or 3 to be max and one to be below.

I dont really know where to start with this, at this stage all i have done is been able to use a percentage to workout where they go. Basic, but no randomness to it without checks. Input will never exceed 4950 as i will make it throw and error if user tries to input higher.




Aucun commentaire:

Enregistrer un commentaire