lundi 22 décembre 2014

How to add two random numbers within a range?

My requirement :--



The sum of the two random numbers will be 100..
sum=random_no1 + random_no2 (the sum will be exact 100)


So,I have tried:--



Random r = new Random();
int Low = 10;
int High = 100;
int R = r.nextInt(High-Low) + Low;

Random r1 = new Random();
int Low1 = 10;
int High1 = 100;
int R1 = r1.nextInt(High1-Low1) + Low1;


but how I define the sum??


I can not understand..Please help me..





Aucun commentaire:

Enregistrer un commentaire