title: Dice Roll Simulation in Java
body: <p>i searched this site and found similar codes but a little different. For my lab in class the instructions say that I need to roll N die , M times and display the number of times a roll occurs in a frequency table. so I'm having a bit of trouble setting up the data in my frequency table. The frequency table prints right but my numbers are wrong. I feel like I'm missing something either and array or an increment? Please Help</p>
  
  <p>my input:</p>
  
  <pre><code>import javax.swing.*;
  import java.awt.*;
  import java.util.*;
  
  public class Lab1
  {
  
  
    public static void main(String[] arg)
    {
         Random ran = new Random();
         String n = JOptionPane.showInputDialog(null,"How many dice?: ");
         String m = JOptionPane.showInputDialog(null,"How many rolls?: ");
         int die = Integer.parseInt(n);
         int roll = Integer.parseInt(m);
         int count = 0;
         int[] rollArr = new int[die*6+1];
  
         for(int i=0;i&lt;rollArr.length;i++)
         {
              rollArr[i] = 0;
         }
  
         for( int i=0; i&lt;roll;i++)
         {
              count = die*1 + ran.nextInt ( 6 );
              ++rollArr[count];
         }
  
         for(int r=1;r&lt;rollArr.length;r++)
              System.out.println(r + ":" + rollArr[r]);
    }
  }
  </code></pre>
  
  <p>The example says to roll 4 dice 1,000,000 times to get a bell curve but my curve has alot of zeroes.
  my output:</p>
  
  <pre><code>1:0
  2:0
  3:0
  4:166309
  5:166424
  6:166523
  7:166984
  8:167286
  9:166474
  10:0
  11:0
  12:0
  13:0
  14:0
  15:0
  16:0
  17:0
  18:0
  19:0
  20:0
  21:0
  22:0
  23:0
  24:0
  </code></pre>