Static42
09-06-2008, 04:17 PM
public class DiceRoll
{
public static void main(String[] args)
{
int diceArray[] = new int[15000];
for (int i = 0; i < 15000; i++)
{
diceArray[i] = 1 + (int) (Math.random() * 7);
}
}
}
That code will output a random number between 1 and 6. After the for loop, I want the program to tell me how many times each number appeared. So for example, let's say out of the 15000 times, the number 8 appeared 400 times. I want the script to calculate that and present me with that number.
for (int pass = 1; pass < diceArray.length; pass++)
{
//code
}
That for loop will go through the entire array. I just need help with finding how many times each number appeared.
{
public static void main(String[] args)
{
int diceArray[] = new int[15000];
for (int i = 0; i < 15000; i++)
{
diceArray[i] = 1 + (int) (Math.random() * 7);
}
}
}
That code will output a random number between 1 and 6. After the for loop, I want the program to tell me how many times each number appeared. So for example, let's say out of the 15000 times, the number 8 appeared 400 times. I want the script to calculate that and present me with that number.
for (int pass = 1; pass < diceArray.length; pass++)
{
//code
}
That for loop will go through the entire array. I just need help with finding how many times each number appeared.