I am trying to use the example in the book that I am reading but I am getting confused with this exercise. I am trying to use a Random object to generate a random integer in the range 1 to 6 for each die. There are 36 possible combinations (6 possible numbers for die 1 times 6 possible numbers for die 20. Repeat this for 360 times. Use a two dimensional rectangular array to count the frequency of each combination. Display the frequency counts.

```
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
public class Dice
{
public static void Main(string[] args)
{
Random randomNumber = new Random();
int[,] rolls = { { 0,0,0,0,0,0 } };
int roll = 0;
while (roll <= 360)
{
int die1 = randomNumber.Next(1, 7);
int die2 = randomNumber.Next(1, 7);
rolls[die1 - 1, die2 - 1]++;
roll++;
}
Console.WriteLine("Overall distribution:");
int[] frequency = new int[361];
foreach (int turn in roll)
{
++frequency[turn / 360];
}
for (int count = 0; count < frequency.Length; count++)
{
if (count == 36)
Console.Write(" 360: ");
else
{
Console.Write("{0:D2}-{1:D2}: ", count * 36, count * 36 + 360);
}
for (int stars = 0; stars < frequency[count]; stars++)
Console.Write("*");
}
}
}
```

If I'm right, the idea is that array element "Frequency[2][4]" would indicate the number of times the 1st die was a 3 (=2 for a zero based array index) and the 2nd die was a 5 (=4 for a zero based array).

So what you want to do is roll the two dice and increment the appropriate array value for the two dice for 360 rolls. Then iterate the array to display the results.

Otherwise, what's the question?

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.

But in any case, the requirement does not include tracking the history of the rolls (i.e. you don't have to know what the 1st roll was vs what the 2nd roll was, etc). You only have to track the number of times each of the 36 possible outcomes happen, so you only need an array with 36 total elements.

Now you can create that array as either a one-dimensional array with 36 elements: [0]=1,1; [1]=1,2 ... [5]=1,6; [6]=2,1; ...[35]=6,6.

You can also create a two-dimensional array with 6 elements in each dimension: [0][0]=1,1; [0][1]=1,2;[5][5]=6,6 (and since the assignment specifies 2-D, you'll want something like this).

From there, you just have to have a loop that rolls the two die 36 times, each time incrementing the appropriate element in the array the roll represents. Then report the results in your array.

What you should find is that if you try something like 360,000,000 rolls (rather than just 360), that the value if each element in the array should be nearly equal as the random number generator should be equally distributing the possible outcomes.

The only array you need is an array to track a count of the 36 possible results. You could do that with a one dimensional array where element [0] = roll of 1,1 while element [2]

Each dimension of the array would hold the number of times Then you can run the test for 360 rolls, 360,000 rolls, or 360,000,000 rolls. As for the type of data in the array, you only have to track the number of times that