Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please look at the pictures above and do the problem. Please do in Java thank you! Consider the class below. It has several methods that
Please look at the pictures above and do the problem. Please do in Java thank you!
Consider the class below. It has several methods that are used to simulate a probability experiment with dice public class Probability ( Returns a random int value 1-6 inclusive, the result of rolling a standard six-sided die Implementation not shown. You do not have to write this method. You should call it from your code public static int dieRollo ! /** Implementation not shown. / 3 with dice, doubles" is when you roll 2 dice and get the same number, for example 6, 3) or (5.5) Given a goal, we are trying to get that many "doubles" in a row. For example, if goal is 3. are trying to get 3 "doubles" in a row, so if we get: (2, 2), (6,5), and (1, 1), then we have reached the goal However they need to be consecutive, so if we get something other than a doubles on one try. have to start over This means that it may take many dice rolls before we get a "run" goal consecutive "doubles The method countries simulates this process, and returns the total number of dice rolls it took to get consecutive run of goal "doubles." For full points, please call dieroll as part of your method, public static int countries(int goal) ** Implemented in Part (0) } The method mintries colls countries num times, and returns the minimum count from all num experiments. This is the experiment that took the fewest tries to get goal doubles in a row For full points, please call countTries as part of your method. You can assume that it works as specified, regardless of your answer to Part (a) - public static int minTries(int goal, int num) { Implemented in Part (b) 2 Examples for Part (a), countries goal Dice rolls: A pair like (a, b) is a pair of die rolls on one "try". Doubles are in bold, Value returned 2 (4,4), (1.2), (6,3), (5,5), (2, 4), (6, 1), (4,3), (5,5), (1, 1) 9 5 2. (4, 6), (3, 3), (1.4), (2, 2), (6, 6) 11 3 (1,2), (4,4), (3, 3), (3, 6), (5, 1), (5,5),(4,3), (6, 1), (1, 1), (3, 3), (1,1) 4 3 (5.1), (5,5), (3, 3), (2, 2) 6 1 (3,2), (6,4), (1,2), (4, 6), (2,5), (3, 3) Examples for Part (b), min Tries Value returned Call Values returned by count Tries(goal). Min value in bold 7 min Tries(210) 12, 15, 18, 13, 15, 7, 39, 22, 27, 14 49 min Tries(3,5) 58, 51, 62, 49, 87 150 min Tries(4,5) 150, 237, 812, 546, 301 1 min Tries(1.10) 6.2.9,5,4,7,2,3,5,1 1(a) Write the count Tries() method below: public static int countTries(int goal) B 1 U EEStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started