Write a java program that simulates thousands of games and then calculate the probabilities from the...

60.1K

Verified Solution

Question

Programming

Write a java program that simulates thousands of games and thencalculate the probabilities from the simulation results.Specifically in the game, throw two dice, the possible summationsof the results are: 2, 3, ..., 12. You need to use arrays to countthe occurrence and store the probabilities of all possiblesummations. Try to simulate rolling two dice 100, 1000, 10,0000times, or more if needed. Choose one simulation number so that theprobabilities you calculated is within 1% absolute error comparedwith the theoretical probability. For example, the theoreticalprobability for summation result 2 is approximately 2.78%, thenyour calculated probability based on simulations should be between2.28% and 3.28%. The following is required:

• Use an array of ints of length 11 to keep count of thedifference occurrences. When an int or double array is created, itsvalues are initialized to 0 by default.

• In the simulation loop, throw the two dice, add the values,and then increase the corresponding array element by 1.

• Turn the occurrence counts into probabilities after thesimulation loop is done.

Answer & Explanation Solved by verified expert
4.4 Ratings (625 Votes)
import javautilRandompublic class    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students