Results 1 to 9 of 9
 11152007, 03:03 AM #1Member
 Join Date
 Nov 2007
 Posts
 38
 Rep Power
 0
 11152007, 03:49 AM #2
int n = (int)(1 + 20*Math.random());
 11152007, 03:50 AM #3Member
 Join Date
 Nov 2007
 Posts
 38
 Rep Power
 0
we cannot use the Math.random function
 11152007, 03:53 AM #4Member
 Join Date
 Nov 2007
 Posts
 38
 Rep Power
 0
this is some code it  Each number needs to be generated.
Each number should be generated at least 300 times of the 10,000.
Java Code:public class Random_Gen { int min; //minimum number that can be generated. int max; //maximum number that can be generated. int value; public Random_Gen(int n, int m) { max = m; //code goes in this class min = n; } public int getRandom() { return value; } } public static void main(String[] args) { int min = 1; // smallest number that can be generated int max = 20; // largest number that can be generated Random_Gen rg = new Random_Gen(min, max); int num; int[] frequency = new int[max]; for (int x = 0; x < 10000; x++) { num = rg.getRandom(); System.out.println(num); for (int index = 0; index < max; index ++) //determines frequency { if (num == index + 1) frequency[index]++; } } for (int index = 0; index < max; index ++) // displays frequency { System.out.println(""+(index+1) + " = " + frequency[index]); } }
 11152007, 04:29 AM #5
Can you use the java.util.Random class?
Edit: random numbers without using java funtions
aha  no java. Check the next method in the Random class for some clues.Last edited by hardwired; 11152007 at 05:01 AM. Reason: read the title
 11152007, 10:45 PM #6Member
 Join Date
 Nov 2007
 Posts
 38
 Rep Power
 0
i dont understand
 11152007, 11:01 PM #7Member
 Join Date
 Nov 2007
 Posts
 8
 Rep Power
 0
carlos,
just like hardwired said there is another java class called Random you can upload before your programs you try something like this
Java Code:java.util.Random; public class RandomProject{ public staid void main(strings[] args){ Random generator = new Random(); //give a object name for the class for(int i=0; i<=100; i++){ int randomNumbers = generator.nextInt(20);//will generate numbers from120 System.out.println(randomNumbers); } } }
 11162007, 03:39 AM #8Member
 Join Date
 Nov 2007
 Posts
 38
 Rep Power
 0
we cannot use any java functions
 11162007, 10:13 AM #9
Similar Threads

Computing prime numbers in Java
By Java Tip in forum java.langReplies: 0Last Post: 04122008, 08:39 PM 
random numbers without random class`
By carlos123 in forum New To JavaReplies: 4Last Post: 01172008, 10:44 PM 
random numbers
By carlos123 in forum New To JavaReplies: 1Last Post: 12222007, 02:56 AM 
generating random numbers in a 5x5 array.
By acidacid in forum New To JavaReplies: 3Last Post: 08142007, 03:44 AM 
How to generate random number in java
By fernando in forum New To JavaReplies: 1Last Post: 08012007, 07:32 PM
Bookmarks