Write a main method that will simulate playing the game

Assignment Help JAVA Programming
Reference no: EM13712991

Question- On the Monty Hall game show, a contestant is given a choice of three doors. Behind one door is a car and behind the other two doors are goats. 

Consider the contestant picks a door, say No. 1, but he does not get to see what is behind it. The host, who knows what is behind all of the doors, opens another door, say No. 3, which he knows has a goat and shows it to the contestant.  He then says to the contestant, "Do you want to stay with door No. 1 or switch to door No. 2?" Is it to the contestant's advantage to switch? Your task is to help the contestant decide whether or not to switch. 

To do this,

Create a class called MontyHallSimulation that represents the game. In this class, write a main method that will simulate playing the game 1000 times. In each play,

- Randomly pick a door from 1 to 3 for the location of the car (use a random number generator). To get an int between 1 and 3 use

int door = (int)(Math.random() * 3.0 + 1.0);

- Randomly pick a door from 1 to 3 for the contestant's choice of door

- Randomly have the host pick a door with a goat, but not the door that the contestant chose

- Increment a counter called strategy1 if the contestant would have won by switching to the host's choice of door, or increment a counter called strategy2 if the contestant would have won by staying with the original choice.

- After 1000 plays, print the results of both counters.

I propose you have to write the program first for one play and print out the values of given variables until you are confident everything is working correctly.  Then include a loop to make it play 1000 times.

Reference no: EM13712991

Questions Cloud

What is the % ionization and the ka value : A weak acid is placed in a beaker of pure water. At equilibrium, HA has a concentration of .05 M and it conjugate base has a concentration of .01 M, as well as [H3O+]. What is the % ionization? And the Ka value?
Implement a function to return a largest integer in array : The first argument of the function is a vector of int and the second argument is the number of consecutive integers to append to the vector starting from 0 and ending at "n - 1".
Implement a javascript program for the validation case : Write a JavaScript program for the validation case using the RegExp method - implement a JavaScript program for the validation case
What is the percent yield of o2 produced in the reaction : What is the mass in grams of O2 gas that was produced in the reaction as described above. What is the percent yield of O2 produced in the reaction
Write a main method that will simulate playing the game : On the Monty Hall game show, a contestant is given a choice of three doors. Behind one door is a car and behind the other two doors are goats.
Organic compound cyclohexanol is converted to cyclohexene : When heated with sulfuric or phosphoric acid, the organic compound cyclohexanol (C6H11OH) is converted to cyclohexene (C6H10). The overall balanced reaction can be represented as:
Write a javascript program for the validation : Write a JavaScript program for the validation case using the RegExp method - If the user enters a valid phone number, convert it to the form (123)456-7890 (if it is not already in this form).
What is the copper concentration in parts per million : An aqueous solution of copper sulfate was found to have an absorbance of 0.168 at 265 nm when measured in a cuvette with a path-length of 0.500cm. If the absorptivity of the transition is 11.5m^2/mol what is the copper concentration in
How far apart is the astronaut : A 94.0kg spacewalking astronaut pushes off a 620kg satellite, exerting a 105N force for the 0.410s it takes him to straighten his arms.

Reviews

Write a Review

JAVA Programming Questions & Answers

  Displays the number of days in a month

Create a program that displays the number of days in a month. Use a 12-element one-dimensional array to store the number of days in each month (use 28 for the number of days in February).

  Objectivesto gain experience with arrays to gain

objectivesto gain experience with arrays. to gain experience with generic algorithms.documentationexplain

  Write a scanner that translates logical expressions

Write a scanner that translates logical expressions. There are many different notations for logical expressions.

  Develop a java program

Develop a Java program which, given the width, length and depth (in metres), of a swimming pool, determines and outputs.

  Write java statements to create a collection of integers

Write Java statements to create a collection of integers, and to initialize each element of the collection to -1. Then, using for each statement to print the value of each element.

  Write a method called sigma

Write a method called sigma that takes an int parameter n and returns the sum of all the integers from 1 to n (inclusive). For example, sigma(4) should return 10.

  Write a class and client class that stores hotels ratings

Write a class and client class that stores hotels ratings over the years. The number of stars represents hotel ratings. Use a two dimensional integer array to represent the years and hotels

  Write a class called palatine

Write a class called palatine that converts an STL string into Pig Latin form. The rules for converting a string into Pig Latin are as follows.

  Create a calculator function

This is the code for my trip planner,you need to figure out how to create a calculator function to enable users to calculate their own costs if they choose

  Create a project in eclipse

Create a new project

  Create system in java using agile approach

You are a software manager in company which designs critical control software for aircraft. Create system in Java using agile approach with a user involved in the development team.

  Explain we have to make a project in java

We have to make a project in java . This is a small deskstop application no specifications given so far . The CD store has CD games and music we can rent a cd or we can buy . This is all we need to develop.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd