On the monty hall game show a contestant is given a choice


Question- On the Monty Hall game show, a contestant is given a choice of three doors. Behind one door is a car and behind the other two doors are goats. 

Consider the contestant picks a door, say No. 1, but he does not get to see what is behind it. The host, who knows what is behind all of the doors, opens another door, say No. 3, which he knows has a goat and shows it to the contestant.  He then says to the contestant, "Do you want to stay with door No. 1 or switch to door No. 2?" Is it to the contestant's advantage to switch? Your task is to help the contestant decide whether or not to switch. 

To do this,

Create a class called MontyHallSimulation that represents the game. In this class, write a main method that will simulate playing the game 1000 times. In each play,

- Randomly pick a door from 1 to 3 for the location of the car (use a random number generator). To get an int between 1 and 3 use

int door = (int)(Math.random() * 3.0 + 1.0);

- Randomly pick a door from 1 to 3 for the contestant's choice of door

- Randomly have the host pick a door with a goat, but not the door that the contestant chose

- Increment a counter called strategy1 if the contestant would have won by switching to the host's choice of door, or increment a counter called strategy2 if the contestant would have won by staying with the original choice.

- After 1000 plays, print the results of both counters.

I propose you have to write the program first for one play and print out the values of given variables until you are confident everything is working correctly.  Then include a loop to make it play 1000 times.

Request for Solution File

Ask an Expert for Answer!!
JAVA Programming: On the monty hall game show a contestant is given a choice
Reference No:- TGS0966248

Expected delivery within 24 Hours