So I'm basically trying to recreate the simulation of two dice being rolled, and I need to count the frequency in a two dimensional rectangular array, then display the array. I'm so lost I wrote some code but it didn't work, can anyone help.
This is the assignment I'm not looking to cheat because I've done some work, I'm just stuck.
reate a C# application to simulate the rolling of two dice. 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;
class RollingDice
{
public static void Main(string[] args)
{
Random randomNumbers = new Random();
int[,] frequency = new int[7, 7];
int[] dice = new int[7];
int[] dice2 = new int[7];
Console.WriteLine("The following example will roll a dice 360 times and display the frequency count!");
for (int totRoll = 1; totRoll >= 360; totRoll++)
{
for (int roll = 1; roll <= 2; roll++)
{
++dice[randomNumbers.Next(1, 7)];
}
for (int roll2 = 1; roll2 <= 2; roll2++)
{
++dice2[randomNumbers.Next(1, 7)];
}
}
for (int x = 1; x <= dice.Length; x++)
{
Console.WriteLine("There are 36 combinations rolled these are the frequencies");
for (int y = 1; y <= dice2.Length; y++)
{
Console.WriteLine("{0} and {1} were rolled: {2}", x, y, frequency[x, y]);
}
}
Console.ReadKey();
} // end Main
} // end class RollingDice