# Programming Problems: Dice Counter

## Question

1. Create a new Class called DiceCounter

2. In DiceCounter, create a field (instance variable) called rollCounter. This will be an array of type int. Also create a field to hold an instance of a Random number generator.

3. In DiceCounter, create a constructor that initializes rollCounter with a size of 11 (i.e., element indexes from 0 to 10) and creates the instance of the Random number generator.

4. In DiceCounter, add a method called Roll. This will "roll" both dice as described in the assignment and add one to the count in the appropriate element in the array. Note that the sum will go from 2 to 12 while the indexes will go from 0 to 10, so adjust accordingly.

5. In DiceCounter, add a method called DisplayResults that loops through the array and displays the sum and the count for each element in the rollCounter array. The output will look like:
SUM      COUNT
---      -----
2       ###
3       ###
4       ###
etc.

6. In your main method, just create a DiceCounter object, loop and call Roll on that object 36,000 times, and then finally call DisplayResults.

## Solution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CH8_17
{
class DiceCounter
{
private int [] rollCounter ;
private Random rand;
public DiceCounter()
{
rollCounter = new int[11];
rand = new Random();
for (int i = 0; i < rollCounter.Length; i++)
{
rollCounter[i] = 0;
}
}...
\$40.00 for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

### Find A Tutor

View available Visual Basic Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.