Total members 11893 |It is currently Tue Nov 05, 2024 11:30 am Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





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().




Author:
Newbie
User avatar Posts: 2
Have thanks: 0 time

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.

_________________
M. S. Rakha, Ph.D.
Queen's University
Canada


Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 time
Post new topic Reply to topic  [ 2 posts ] 

  Related Posts  to : java program
 java program     -  
 email through JAVA program     -  
 java chat program.     -  
 Executing a Java Program     -  
 compiling and getting of a java program     -  
 Elements of a Java Program     -  
 Java Chat Program between two computers     -  
 Need Java program for display the CPU usage     -  
 Java Program for communicate PC and Mobile     -  
 uploading text file to java program     -  









Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
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