Way back in the 1970's, there was a goofy television game show know as, Let's Make a Deal. As a member of the audience, you were expected to dress in a manner that sacrified as much dignity as possible, thus gaining the attention of the host who would select you as a participant. Once selected by the host, here's how the game worked:
The big question: If you were a contestant on the show, then, when you reached the final step, would you elect to switch or to stay? Probabilistically, does it matter?
We could try to use our brains to reason out the answer to this question, but why do that when you can have the computer play the game thousands of times, keeping track of whether you should have switched or stayed? That is what we will do...
Write a program, named MakeADeal, that simulates the playing of this game. Specifically, it should:
At the beginning of the program, the user should be prompted to enter the number of repetitions of the game that should be simulated, known as the number of trials. Once that value (a positive integer) is provided, the above set of steps should be performed that many times. With each iteration of the game, the program should sum the number of times that switching would have won and the number of times staying would have won.
The program should, as it runs, show what's happening with each simulation of the game. It should also show the results at the end. With each game simulated, the program should print the following information:
The number of the door that contains the prize.
The number of the door initially guessed by the simulated contestant.
The number of the door shown by Monty Hall that has a dud prize.
Whether staying or switching would be the correct move for the player under this circumstance.
After all of the trials have been performed, the program should print the number of times the contestant would have won by switching, and the number of times she would have won by staying. Specifically, the output should have exactly this format:
Number of trials? 2 Prize: 2 Guess: 2 Shown: 1 STAY to win Prize: 0 Guess: 2 Shown: 1 SWITCH to win Switch would win: 1 Stay would win: 1
When your work is complete, use the cs11-submit program again. For this lab, you will submit your work with the following command at the shell prompt:
cs11-submit project-1 MakeADeal.java