100% Guaranteed Results


PCS – 1. Write a program that simulates rolling 2 dice. Roll the 2 dice 36,000 times and keep track of how many times you get each result (i.e total of the 2 dice). Solved
$ 29.99
Category:

Description

5/5 – (1 vote)

Hint: If you want a step-by-step on how to:
a. Create a method rollDie that uses Math.random() to pick a number from 1 to 6 and returns the number.
b. Create a method rollDice that calls the rollDie method twice to get the total of the two dice and returns the total.
c. Create a one dimensional array to store the number of times for each result. i.e. initially the array has all zeros. If you roll a 2, increment the 2 spot in the array so it will become 1. If you then roll another 2, increment it again so it becomes 2. If you roll a 9, increment the 9 spot.
d. Write a loop in the main method that loops 36,000 times calling the rollDice method and tracking the results in the array.
e. Print out how many times each total was rolled.

Reviews

There are no reviews yet.

Be the first to review “PCS – 1. Write a program that simulates rolling 2 dice. Roll the 2 dice 36,000 times and keep track of how many times you get each result (i.e total of the 2 dice). Solved”

Your email address will not be published. Required fields are marked *

Related products