Thu Nov 08, 2012 11:13 am
c. Write an efficient Program to print the following two outputs.
You are given a pre-defined function named getrnd50() which returns an integer which is one random number from 1-50. You can call this function as many times as you want but beware that this function is quite resource intensive. You cannot use any other random generator. You can NOT change the definition of getrnd50().
int getrnd50(){
Random rand = new Random();
return (1+rand.nextInt(50));
}
Output1: Print numbers 1-10 in random order. (Not 10 random numbers)
Output2: Print numbers 1-100 in random order. (Not 100 random numbers)
Note:
i. Every number should be printed exactly once.
ii. There should be no pattern in the numbers listing. List should be completely random i.e., all numbers have equal probability appearing at any place.
iii. You may call getrnd50() any number of time to get random number from 1 to 50.
iv. You cannot use any other random generator function except getrnd50().
Thu Nov 08, 2012 4:38 pm
Dear Bro,
this looks an assignment , you have to start coding and if u faced a problem, just post the code and we will help u.
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com
Powered by phpBB © phpBB Group.