title: 3 Dice Sum Counting Program Java
body: <p>For my Computer Science Class, my teacher is asking us to do the following: </p>
  
  <p>Program Description:  You are learning to play a new game that involves 3 six-sided die.  You know that if you knew the probability for each of the possible rolls of the die that you’d be a much better competitor.  </p>
  
  <p>Since you have just been studying arrays and using them to count multiple items that this program should be a snap to write.  This will be cool since the last time we did this we work just looking for how many times 9 or 10 could be rolled and this program won’t require any if statements.</p>
  
  <p>Required Statements:  output, loop control, array</p>
  
  <p>Sample Output:</p>
  
  <p>Number   Possible Combinations</p>
  
  <p>1                0</p>
  
  <p>2                0</p>
  
  <p>3                1</p>
  
  <p>4                3</p>
  
  <p>5                6</p>
  
  <p>6               10</p>
  
  <p>7               15</p>
  
  <p>8               21</p>
  
  <p>9               25</p>
  
  <p>10               27</p>
  
  <p>11               27</p>
  
  <p>12               25</p>
  
  <p>13               21</p>
  
  <p>14               15</p>
  
  <p>15               10</p>
  
  <p>16                6</p>
  
  <p>17                3</p>
  
  <p>18                1 </p>
  
  <p>I can easily do this with an if statement, but I don't understand how to do it without one. It is especially tricky because under hints, she wrote: "These programs utilize a counting array. Each time a value is generated the position at that index is incremented. It’s like the reverse of the lookup table." I have no idea what this means.</p>
  
  <p>Here's my code with the if statement:</p>
  
  <pre><code>public class prog410a
  {
      public static void main(String args[])
      {
          System.out.println("Number\tPossible Combinations");
  
          for (int x = 1; x &lt;= 18; x++)
          {
              int count = 0;
              for (int k = 1; k &lt;= 6; k++)
              {
                  for (int i = 1; i &lt;= 6; i ++)
                  {
                      for (int j = 1; j &lt;= 6; j++)
                      {
                          if (k + i + j == x)
                              count++;
                      }
                  }
              }
              System.out.println(x + "\t\t\t" + count);
          }
  
      }
  }
  </code></pre>
  
  <p>So I guess my overall question is this: How can I emulate this, but by using some sort of array instead of an if statement?</p>