C++ Program that simulates Monty Hall Puzzle
How to win a car!??
Monty Hall was a popular game show host on American television. Assume , you are a contestant from the studio audience. He shows you three doors,Door #1, Door #2, and Door #3. Hidden behind one door is a brand new car, and behind each of the other two doors is a goat.
Monty asks you to pick a door. Of course, you want to pick the right door and win the car. Monty knows which door hides the car. After you’ve picked a door, he opens one of the other doors and shows you a goat. Monty then offers you a chance to stay with the door you originally picked, or you can switch your choice to the remaining third door. Would staying or switching be better?
The simulation: C++ program to simulate the above scenario. The program does the following:
- Randomly pick a door to hide the car.
- Acting as you, randomly pick a door as your first door choice.
- Acting as Monty, open a door to reveal a goat. Since Monty (i.e., the program) knows which door hides the car: a. If your first door choice was correct, the other two doors each hides a goat. Monty randomly chooses one of the two doors to open. b. If your first door choice was incorrect (your door hides a goat), Monty opens the other door that hides a goat.
- This leaves a third door to which you can switch as your second door choice. The program should keep track of whether you win by staying with your first door choice or if you win by switching to your second door choice.
The simulation is made to run 100 times.
How many times do you win by staying with your first door choice vs. switching to a second door choice? Does it make a difference? What is the ratio of second door choice wins to first door choice wins?
You can see answers to above questions in the sample output of simulation in the attachment.