Just a quick question on how to start off a code on this. The program is supposed to simulate tossing a pair of 2-sided dice and determining the percentage of times each possible combination of the dice is rolled. The actual assignment is using 11-sided dice but I just want a simple code to start off with. I want to make it into one loop using for, if, and nested loops. How would a code like this look?
Things I Need
Loop to increment through the possible sums of the dice
for (int sum = 2; sum <= 4; sum++)
Loop to throw dice given number of times
for (int roll = 0; roll < totalRolls; roll++)
Randomly generate values for two dice
die1 = (int)(Math.random() * 10); die2 = (int)(Math.random() * 10); diceSum = die1 + die2;
Check if the sum of dice is equal to the given sum