Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a GUI program that simulates the rolling of two 6-sided dice. Use an Array to keep track of the number of times that each

Write a GUI program that simulates the rolling of two 6-sided dice. Use an Array to keep track of the number of times that each total number is thrown. In other words, keep track of how many times the combination of the two simulated dice is 2, how many times the combination is 3, and so on, all the way up through 12. Hint: You need to use random in order to simulate the dice. For example, the first roll might produce two 1s (also known as snake eyes). This adds to the number 2. Another roll might produce a 3 and a 4, which adds up to 7. A third roll might produce a 5 and a 2, which adds up to 7. At this point your array would hold the following values: index: 0* 1* 2 3 4 5 6 7 8 9 10 11 12 value: 0 0 1 0 0 0 0 2 0 0 0 0 0 *Note that the values of 0 and 1 are impossible with two dice. Allow the user to choose how many times the dice will be thrown. The number can only be between 100 and 1000. Use a slider to let the user choose only between 100 and 1000. (Make sure to set the minimum value of the slider to 100 and the maximum value of the slider to 1000). You will use at least the following GUI controls (you can use others as well, like Labels, if you want): Slider (have an associated Label that shows the current value) Button TextArea After the person selects the number with the slider (between 100 1000) then simulate the dice rolls when the person presses the button. Once the dice have been thrown the specified number of times (based on the slider), print a histogram (using the * character) that shows the total percentage each number was rolled. Each * will represent 1% of the total rolls. So, there should be approximately 100 *s shown.

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

DB2 9 For Linux UNIX And Windows Advanced Database Administration Certification Certification Study Guide

Authors: Roger E. Sanders, Dwaine R Snow

1st Edition

1583470808, 978-1583470800

More Books

Students also viewed these Databases questions