- 3

# Need some help Java, Pair Of Dice

Write a program that rolls a pair of dice until the sum of the number rolled is a specific number. We also want to know the number of times the dice are rolled to get the desired sum. The smallest number or each die is 1 and the larges number is 6. So the smallest sum of the numbers rolled is 2 and the largest sum of the numbers rolled is 12. We use the random number generator, to randomly generate a number between 1 to 6. a. Create a statement that randomly generates a number between 1 to 6 and stores that number into die1, which becomes the number rolled by die1. b. Similarly, create a statement that randomly generates a number between 1 to 6 and stores that number into die2, which becomes the number rolled by die2. c. Next, determine whether sum contains the desired sum of the numbers rolled by the dice. If does not contain the desired sum, then we roll the dice again. (This can be accomplish by using do while loop). d. Create a method named rollDice that takes as a parameter the desired sum of the numbers 0 https://code.sololearn.com/c89b49SFrQ6J/?ref=app

8th Apr 2022, 9:48 AM
+ 2
Name your class Dice or RollEm but decide for one. You haven't used the set-method anywhere. You need a variable for the "desired sum". Run a while loop and roll dice on each iteration. If the sum of the current roll is equal to the desired sum, break, else keep rolling the dice. If the loop works, you can put it in an own function to meet task d).
9th Apr 2022, 7:15 AM
Lisa
+ 1
Well, then write a program... If you need help, please LINK your code so we can see what is going on
8th Apr 2022, 11:15 AM
Lisa
+ 1
11th Apr 2022, 9:17 AM
Lisa
9th Apr 2022, 5:24 AM
0
Here I'm sorry i forgot to link it
9th Apr 2022, 5:24 AM