Question: JAVA. Please don't copy anyone else code b/c it is wrong. Thanks package homework;| import stdlib.Stdout; import stdlib.Std Random; /* * The class PairofDice implements
JAVA. Please don't copy anyone else code b/c it is wrong. Thanks

package homework;| import stdlib.Stdout; import stdlib.Std Random; /* * The class PairofDice implements some basic functionality * of a pair of dice. You may not add any methods to this class * other than those indicated below. public class PairofDice { private int diei, die2; public PairofDice() { // constructor roll(); public void roll() { //_randomize the dice values diel = StdRandom.uniform(1, 7); // returns a random number from 1 to 6 die2 = StdRandom.uniform(1, 7); public boolean isDoubles() { // determines if the two die values are the name return diel == die2; public int sum() { // the the sum of the two die values return diel + die2; // ToDo 1 // add an instance method that determines if the current dice sum is 7 or 11 // return true or false // ToDo 2 // add an instance method that determines if both dice are odd. // hint boolean -------- testing program ---- /* experiment 1 * Q. how many rolls does it take (on the average) to roll a seven or eleven? * first write a loop to count the number of rolls needed to roll a seven or eleven For example if the rolls were: 28 3 5 12 11 it took 6 rolls to get an 11 (this time * then add code to repeat that test 1,000,000 times. * return: the average (number of rolls needed) of all the tests * hint: nested loops, use the seven0rEleven instance method public static double experiment One PairofDice x) { return -1.6; // ToDo 3 * experiment 2 * Question: What is the likelihood of rolling odd-valued doubles ? * To answer this, complete this function which * should roll the dice 1,000,000 times and * determine and return the percentage of rolls that are doubles * with an odd die value. (1,1) or (3,3) or (5,5) she comes to one on one sing odd-valued d * Hint: you will need to used instance methods of the Pairoflice class public static double experiment Two PairofDice x) { return -1.6; // ToDo 4: // nothing to do here public static void main(String[] args) { PairofDice myDice = new Pairof Dice(); double rollsToGetor11 = experiment One (myDice); double probOdd Doubles = experimentTwo (myDice); Stdout.format(" The average number of rolls to get a 7 or 11 was 45.3f ", rolls ToGet7or11); Stdout.format("The experimental probablity of rolling odd doubles is 45.3f ", probOddDoubles)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
