Finish the simulation program of the “Monty Hall paradox” that was discussed in class. Your…

Finish the simulation program of the “Monty Hall paradox” that was discussed in class. Your program should ask the user if she wants to “always switch” or “never switch” and then silently simulate the game 10,000 times given this decision. Don’t repeatedly ask the user for her decision on each trial! Don’t print out any debugging text! Print out only the overall fraction of times the player wins the fabulous grand prize.

Completing the simulation:

*Add game methods for

  • Monte choosing a door to open
  • The player switching or not
  • Deciding if the player has won

*Add PlaymanyGames code to

  • Call the new game methods
  • Put everything in a loop
  • Prompt the user for # of trials, switching policy
  • Display the results

There are three classes already made:

  • Door.java
  • Game.java
  • PlaymanyGames.java

Here is the code for Door.java:

1 package monte;

2 public class Door {

3 protected boolean open;

4 protected boolean hasGrandPrize;

5 protected boolean chosenByContestant;

6 // for debugging

7 public String toString() {

8 return (open ? “is open, ” : “is not open, “) +

9 (hasGrandPrize ? “is the grand prize, and “

10 : “is not the grand prize, and “) +

11 (chosenByContestant ? “is chosen.” : “is not chosen.”);

12

13 }

14 }

*****************************************************************

Here is the code for Game.java:

1 package monte;

2 import java.util.*;

3 public class Game {

4 static Random r = new Random();

5

6 private Door door1, door2, door3;

7 /**

8 * Call this first

9 */

10 public void setUpGame() {

11 door1 = new Door();

12 door2 = new Door();

13 door3 = new Door();

14 // Java initialized all of the

15 // Door variables to false on construction.

16 int grandPrizeDoor = r.nextInt(3);

17 switch(grandPrizeDoor) {

18 case 0:

19 door1.hasGrandPrize = true;

20 break;

21 case 1:

22 door2.hasGrandPrize = true;

23 break;

24 case 2:

25 door3.hasGrandPrize = true;

26 break;

27 }

28 }

29

30 /**

31 * Sanity check output

32 */

33 public void printStateOfDoors() {

34 System.out.println(“Door 1 ” + door1.toString());

35 System.out.println(“Door 2 ” + door2.toString());

36 System.out.println(“Door 3 ” + door3.toString());

37 }

38 /**

39 * randomly make first choice for contenstant.

40 */

41 public void contestantChooseDoor() {

42 int contestantDoor = r.nextInt(3);

43 switch(contestantDoor) {

44 case 0: door1.chosenByContestant = true;

45 break;

46 case 1: door2.chosenByContestant = true;

47 break;

48 case 2: door3.chosenByContestant = true;

49 break;

50 }

51 }

52

53 }

54

*****************************************************************

Here is the code for PlaymanyGames.java:

1 import monte.Game;

2

3

4 public class PlayManyGames {

5 /**

6 * This program takes no arguments.

7 * Currently this program plays zero games.

8 */

9 public static void main(String[] args) {

10 Game theGame = new Game();

11 theGame.setUpGame();

12 theGame.printStateOfDoors();

13 theGame.contestantChooseDoor();

14 theGame.printStateOfDoors();

15 }

16 }

*****************************************************************

Here is an image of what the code prints when I run PlaymanyGames.java

Finish the simulation program of the

Could you please make additional changes to the code I already have? Also, please leave comments so I can understand what’s happening. Also, the code for door.java does not have to change.

Place your order
(550 words)

Approximate price: $22

Calculate the price of your order

550 words
We'll send you the first draft for approval by September 11, 2018 at 10:52 AM
Total price:
$26
The price is based on these factors:
Academic level
Number of pages
Urgency
Basic features
  • Free title page and bibliography
  • Unlimited revisions
  • Plagiarism-free guarantee
  • Money-back guarantee
  • 24/7 support
On-demand options
  • Writer’s samples
  • Part-by-part delivery
  • Overnight delivery
  • Copies of used sources
  • Expert Proofreading
Paper format
  • 275 words per page
  • 12 pt Arial/Times New Roman
  • Double line spacing
  • Any citation style (APA, MLA, Chicago/Turabian, Harvard)

Our guarantees

Delivering a high-quality product at a reasonable price is not enough anymore.
That’s why we have developed 5 beneficial guarantees that will make your experience with our service enjoyable, easy, and safe.

Money-back guarantee

You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.

Read more

Zero-plagiarism guarantee

Each paper is composed from scratch, according to your instructions. It is then checked by our plagiarism-detection software. There is no gap where plagiarism could squeeze in.

Read more

Free-revision policy

Thanks to our free revisions, there is no way for you to be unsatisfied. We will work on your paper until you are completely happy with the result.

Read more

Privacy policy

Your email is safe, as we store it according to international data protection rules. Your bank details are secure, as we use only reliable payment systems.

Read more

Fair-cooperation guarantee

By sending us your money, you buy the service we provide. Check out our terms and conditions if you prefer business talks to be laid out in official language.

Read more
error: Content is protected !!