Question: ( Uses Java ) Background In the last activity, you created a Monty Hall Simulator that would ask the user for a door. The Monty

(Uses Java)
Background
In the last activity, you created a Monty Hall Simulator that would ask the user for a door. The Monty Hall Problem states that a contestant would increase their odds of winning if they
actually switched doors. In fact, their odds of winning go from 33% for not switching to 66% if you switch.
The math of this is much more confusing than it is to just simulate the results, so in this activity, you are going to create a simulator that can execute the Monty Hall Problem without user
input. From there, you can execute the simulator thousands of times and print out the results.
The Simulator
In this activity, you will create a method that will take whether or not a user will switch doors as an input and return whether or not they win. Specifically, the method should have this
header:
public static boolean runSim(boolean switchDoor)
Inside this method, you can use much of your work from the previous activity, but replace the user door selection with a random number for the door. Whether the user switches will be
based on the parameter passed in, but all other rules around opening the door and winning are the same as the previous exercise.
Running the Simulator
Once the simulator is available to run and return a result, you will want to simulate thousands of runs using a loop in the main method. This loop should count how many times the
contestant would win and then print out the results. Remember, we are expecting the user to win about 23 rd of the time when they switch and 13 rd of the time when they don't switch.
Sample Output:
Switch? false
33.33%
Switch? true
66.73%
 (Uses Java) Background In the last activity, you created a Monty

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!