Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please help with this C# prompt to create a dice-rolling simulator with a one-dimensional array. Sample outputs are included and any help would be appreciated!

Please help with this C# prompt to create a dice-rolling simulator with a one-dimensional array. Sample outputs are included and any help would be appreciated!

Specification:

Yosemite Sam, owner of the Rising Gorge Saloon, is considering introducing gaming to his establishment. To determine how the house can win at dice games, he wants to understand the probabilities associated with hitting a specific number when rolling two dice. He has contracted with ACME Industries Simulation Division to create a dice-rolling simulator.

The simulator is to work as follows:

- Display a nice banner explaining the simulation in brief.

- Read a value from the user that tells how many times to roll the dice. Any positive whole number is acceptable. If the user enters a non-numeric value or non-positive value, use the default number of rolls: 100,000.

- Simulate rolling two dice using the Random class the number of times specified.

- Tally how many times each possible combination of pips appears. Note that each die has values 1 through 6, so the possible number of pips runs from 2 to 12, inclusive.

-At the end of the simulation, print the following:

- A table of the results. For each row, print two columns:

1. The number rolled (2-12), and

2. A count of times that number is rolled.

- Accumulate the total number of rolls and print it as a total row. This is a check to ensure the correct number of rolls was executed.

Required coding features and hints:

  • Represent the default number of rolls as a constant.
  • Use the Random class for each roll.
  • Use a single one-dimensional array with 11 elements to hold the count of each roll value (2 12).

Bonus features:

1. At the end of each simulation, ask the user whether they would like to run another simulation. If they do, start back at the top asking how many simulated rolls, etc. Note: dont forget to reset the array.

2. Add a column that shows the percentage of rolls for each possible combination. Add up the percentages so that in the Total row at the bottom, you can prove that the percentages add up to 100%.

a. Use the Percent format character to print each percentage.

b. Print each percentage with two decimal places (e.g., 13.45%).

c. For the Total percentage value, show the percentage with NO decimal places.

image text in transcribed

Sample output for Homework 4.1 full credit In the example interaction below, data typed by the user appears highlighted and in boldface. ACME Industries Simulation Division ****** Dice Rolling Simulation v. 1.1 One row per possible roll of two dice How many rolls would you like to simulate? >> 100000 Roll Count 2 2,868 3 5,595 4 8,341 5 5 10,982 6 13,868 7 16,712 8 13,843 9 9 10,984 16 8,365 11 5,588 12 2,854 100,000 Press any key... Sample output for Homework 4.1 with bonus features In the example interaction below, data typed by the user appears highlighted and in boldface. *********** ACME Industries Simulation Division ****** Dice Rolling Simulation v. 1.1 One row per possible roll of two dice Including bonus features!! How many rolls would you like to simulate? >> 1000000 Roll Count Pct 2 27,991 2.80 % 3 55,706 5.57 % 4 83,397 8.34 % 5 110,983 11.10 % 6 139,093 13.91 % 7 166,142 16.61 % 8 139,420 13.94 % 9 110,651 11.07% 10 83,771 8.38 % 11 55,111 5.51 % 12 27,735 2.77 % 1,000,000 100 % To runi another simulation, enter "Y": n

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Securing SQL Server Protecting Your Database From Attackers

Authors: Denny Cherry

1st Edition

1597496251, 978-1597496254

More Books

Students also viewed these Databases questions

Question

What accommodations might be helpful?

Answered: 1 week ago

Question

3. Evaluate a Web-based training site.

Answered: 1 week ago