Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Do not use java built in Random Function to generate random number.

706710Mar 21 2013 — edited Mar 28 2013
Language Core Java 1.5 (do not use Random function of java)

Write a methodA that returns a random number between 0 to 3, Use the same methodA to return a random number between 0 and 7. (do not use Random function) .This is a question which comes under uniform distribution principle.

Assume i write a methodA and i have to dynamically pass either 0 or 1 or 2 or 3 to the same methodA,this methodA should display a number between 0 to 7

Rand3(int input) should return dynamically either 0 or 1 or 2 or 3
The same Rand3(int input) should then return any value between 0 to 7.

Language is Core Java 1.5
Solution in Core Java Needed
     Step1:   
   Rand3(int input){   
     //how do i return either 0,1,2,3 dynamically to Rand3() function   
   }   
  
Step2:pass either 0,1,2,3 to same Rand3 function   
Rand3(either 0,1,2,3)   
     // generate a number between 0 and 7   
}  
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 25 2013
Added on Mar 21 2013
32 comments
1,244 views