Answered step by step
Verified Expert Solution
Question
1 Approved Answer
( Question requires java ) After the user selects a door, you need to reveal one of the doors using the following logic. If the
Question requires java After the user selects a door, you need to reveal one of the doors using the following logic. If the user selected the same door as the prize door, you should randomly select one of the other
two doors to reveal. If the user selected a different door than the prize door, you should reveal the door that is not the prize door and is not the door they selected.
After revealing a door, you will ask the user if they want to switch. If they do switch, the user's selected door will become the door that you did not reveal and was not their original door
Finally, with their door selection finalized, the user will win if their selected door matches the prize door.
Sample Outputs:
Welcome to Let's Make a Deal!
Pick a door, or :
You picked door
I opened door
Switch doors true or false: false
You win!
Welcome to Let's Make a Deal!
Pick a door, or :
You picked door
I opened door
Switch doors true or false: true
You switched to door
Sorry, you lose.Background
The Monty Hall Problem or Paradox is a mathematical brain teaser that is based on the classic game show Let's Make a Deal. On the show where Monty Hall is the host, the final deal asks
the contestant to pick one of three doors. Behind one door is the grand prize.
After contestants pick a door, Month Hall reveals one of the two doors that was not picked. He then asks the contestant if they want to stick with their original choice or switch to the other
door.
A majority of contestants choose to stick to their original choice. On the surface, it seems like the question of switching is a personal choice, however, when you switch, you actually double
your odds of winning the grand prize!
In this project, you are going to simulate this activity over a large number of iterations to demonstrate the results.
Setting up the Simulator
In this first activity, you are going to run the problem as if you were the game show host. You will use a random number generator to pick a door, then prompt the user for their choice. After
revealing one of the doors, you will then prompt the user to see if they want to switch their door. After finalizing their door, you will let the user know if they won.
Program Details
There are a few details that you need to follow, but how you implement the solution will be up to you.
First, you will need to prompt the user twice. The first prompt should be for an integer or The second prompt will be for a boolean true or false value. If you don't prompt the user for
these two values in that order, the autograder will fail.
After the user selects a door, you need to reveal one of the doors using the following logic. If the user selected the same door as the prize door, you should randomly select one of the other
two doors to reveal. If the user selected a different door than the prize door, you should reveal the door that is not the prize door and is not the door they selected.
After revealing a door, you will ask the user if they want to switch. If they do switch, the user's selected door will become the door that you did not reveal and was not their original door
Finally, with their door selection finalized, the user will win if their selected door matches the prize door.
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