0

Well, I have finished one of my programs and have been tracing it over and over. Trying to figure out my problem and I just can't seem to figure it out so I have decided to try and let another pair of eyes look at it. A very simple program.

The idea of it is to let the user enter the sides of a dice, the number of dice to roll, and the number of rolls.

```
/*Kevin, september 14
* DiceRolls.java from Chapter 10
* Generate counts of dice roll outcomes.
*/
/**
* Dice are rolled and the outcome of each roll is counted.
*/
import java.util.Scanner;
import java.util.Random;
public class DiceRolls1 {
public static void main(String[] args) {
int[] outcomes;
Scanner input = new Scanner(System.in);
int numRolls;
int sidedDice;
int outcome;
int max;
int numDiceRolled;
Random rand = new Random();
outcome = 0;
System.out.println("Enter the number of sides on the dice ");
sidedDice = input.nextInt();
System.out.println("Enter the number of dice to roll");
numDiceRolled = input.nextInt();
/* prompt user for number of rolls */
System.out.println("How many rolls? ");
numRolls = input.nextInt();
max = (sidedDice * numDiceRolled + 1);
outcomes = new int[max]; //array with indices whatever the possibilities are
for (int roll = 0; roll < numRolls; roll++) {
/* roll dice and add up outcomes */
for (int die = 0; die < numDiceRolled; die++) {
outcome += ( rand.nextInt(sidedDice) + 1);
outcomes[outcome] += 1;
}
}
/* show counts of outcomes */
for (int i = numDiceRolled; i <= max; i++) {
System.out.println(i + ": " + outcomes[i]);
}
}
}
```