# I need help with homework

#### Goldenrtvr

i need help. i am trying to generate 2000 numbers between the values of 10 and 30, then use a one dimensional array to record the frequency of each numbers.
problem is, i am very confused and dont know how to do this. how do i do this? here is the code.

import java.util.Arrays;
import java.util.Random;
import java.util.Scanner;
class Main {
public static void main(String[] args) {
double[] arr = new double[2000];
Random randNum = new Random();
for (int i = 0; i < 2000; i++) {
arr = randNum.nextInt();
}
}
}

#### CodeMonkeyJ

I appreciate you posting what you have so far (next time, try code tags). So, to start, the array that you're creating should be an integer array that covers the range of values you're generating, so we'll use a size of 30. Next, to generate a random number between two numbers, you use `randNum.nextInt(RANGE) + MINIMUM` (`RANGE` being `MAXIMUM - MINIMUM`). Last, to store the frequency, use the random number you've generated as the array index and increment that value.

Java:
``````import java.util.Arrays;
import java.util.Random;
import java.util.Scanner;
class Goldenrtvr {
public static void main(String[] args) {
int[] arr = new int[30];
Random randNum = new Random();
for (int i = 0; i < 2000; i++) {
arr[randNum.nextInt(20) + 10]++;
}
for (int i=10;i<30;i++){
System.out.println(i + ": " + arr[i]);
}
}
}``````