Answered step by step
Verified Expert Solution
Question
1 Approved Answer
The following describes the steps that you be taking: 1. You will prompt the user to enter the number of times he or she wants
The following describes the steps that you be taking: 1. You will prompt the user to enter the number of times he or she wants to play this game. 2. You will create a variable to keep track of the number of times the contestant wins by switching. 3. Generate a random number between 1 and 3 (inclusive) that will denote the door that conceals the prize. 4. Generate another random number between 1 and 3 (inclusive) that will denote the guess the contestant makes. 5. From those two numbers, compute a number that does not conceal the prize nor is it the contestant's guess. This is the door that is opened by Monty Hall and we shall call it view. 6. At this point the contestant changes his mind makes a newGuess that is not the original guess nor is it the view. 7. You will compare the value of the newGuess with that of prize. If they are the same, the contestant won by switching, and you increment the variable that was keeping track of that. 8. You will run this simulation for however many times the user had specified. 9. To obtain the probability for winning if you switch divide the number of times the contestant wins by switching by the total number of games played. 10. To obtain the probability of winning by not switching subtract the above number from one. A sample session and output will look as follows: Enter number of times you want to play: 10 Prize Guess View New Guess WWNNNN NWNNW Probability of winning if you switch - 0.70 Probability of winning if you do not switch - 0.30 Your output must be in the above format. The column headers and the numbers are centered. The probabilities are expressed correct to 2 places of decimal.
Step 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