title: A Program for Simulating the Rolling of 2 Dice
body: <p>The following is the whole question.</p>
  
  <blockquote>
    <p>Write a program that simulates the rolling of two dice. The program
    should use rand to roll the first die and should use rand again to
    roll the second die. The sum of two values should then be calculated.
    [Note : Each die can show an integer value from 1 to 6, so the sum of
    the two values will vary from 2 to 12, with 7 being the most frequent
    sum and 2 and 12 being the least frequent sums.] Note that there are
    36 possible combinations of the two dice. Your program should roll the
    two dice 3,600 times. Use a one_dimensional array to tally the numbers
    of times each possible sum appears. Print the results in a tabular
    format. Also, determine if the totals are reasonable (i.e., there are
    six ways to roll a 7, so approximately one-sixth of all the rolls
    should be 7).</p>
  </blockquote>
  
  <p>The result should be the following : </p>
  
  <pre><code>Question 2
  Please enter the seed : 2
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/9H3iy.png" alt="enter image description here"></p>
  
  <p>I don't know how to generate the "expected" column.
  <img src="https://i.stack.imgur.com/wiT4D.png" alt="enter image description here"></p>
  
  <p>Here is my program : (The main is Q2_main())</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;iomanip&gt;
  #include &lt;cstdlib&gt;
  using namespace std;
  
  double total_Array[11];
  double expected_Array[11];
  double actual_Array[11];
  int seed;
  
  void initialization_of_Array()
  {
      for (int counter=0; counter &lt; 12; counter++)
      {
          total_Array[counter] = 0;
          expected_Array[counter] = 0;
          actual_Array[counter] = 0;
      }
  }
  
  void show_heading_line()
  {
      cout &lt;&lt; setw(5) &lt;&lt; "Sum" 
          &lt;&lt; setw(10) &lt;&lt; "Total" 
          &lt;&lt; setw(17) &lt;&lt; "Expected" 
          &lt;&lt; setw(16) &lt;&lt; "Actual" 
          &lt;&lt; endl;
  }
  
  void show_Data_Results_line(int sum, int total, double expected, double actual)
  {
      cout &lt;&lt; setw(5) &lt;&lt; sum
          &lt;&lt; setw(10) &lt;&lt; total
          &lt;&lt; setw(16) &lt;&lt; expected &lt;&lt; "%"
          &lt;&lt; setw(15) &lt;&lt; actual &lt;&lt; "%"
          &lt;&lt; endl;
  }
  
  void calculation_of_total()
  {
      int die_1, die_2;
      for (int counter = 1; counter &lt;= 3600; counter++)
      {
          die_1 = 1 + rand() % 6;
          die_2 = 1 + rand() % 6;
          total_Array[((die_1 + die_2)-2)]++;
      }
  }
  
  void calculation_of_expect()
  {
  
  }
  
  void calculation_of_actual()
  {
      for (int counter = 0; counter &lt; 11; counter++)
      {
          actual_Array[counter] = (total_Array[counter] / 3600.0) * 100.0;
      }
  }
  
  void rollDice_Operation()
  {
      calculation_of_total();
      calculation_of_expect();
      calculation_of_actual();
  }
  
  void print_Result()
  {
      show_heading_line();
      for (int counter = 0; counter &lt;= 10; counter++)
      {
          show_Data_Results_line((counter+2), total_Array[counter], 1, actual_Array[counter]);
      }
  }
  
  void Q2_main()
  {
      cout &lt;&lt; setprecision(3) &lt;&lt; fixed;
      initialization_of_Array();
      cout &lt;&lt; "Please enter the seed : ";
      cin &gt;&gt; seed;
      srand(seed);
      rollDice_Operation();
      print_Result();
  }
  </code></pre>
  
  <p>Anyone can give me some hints to deal with the "expected" column?</p>
  
  <hr>
  
  <p><strong><em>Thank you for your attention</em></strong></p>