Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

write code in java In this programming assignment, you are going to simulate the game show and demonstrate that Indeed Marilyn vos Savant gave sensible

write code in java
image text in transcribed
In this programming assignment, you are going to simulate the game show and demonstrate that Indeed Marilyn vos Savant gave sensible advice. The following describes the steps that you will 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. Generate another random number between 1 and 3 (inclusive) that will denote the guess the contestant makes 3. 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 Shop tot Prize Guess View New Guess 2 -Prize randomly generated - Cannot show the same door the price in I can't be 3 the same a NNN NWNNWWW- 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. double ty front

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

MySQL Crash Course A Hands On Introduction To Database Development

Authors: Rick Silva

1st Edition

1718503008, 978-1718503007

More Books

Students also viewed these Databases questions