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

  Vehicle in vehicle.java

Create a class called Vehicle in Vehicle.java with instance variables make (such as Ford, GM, Chrysler, Toyota, or Honda), year, and horsepower (200, 300, and 400). Add the necessary constructor and set and get methods.

  Study the code and implement the operator overloading

The Table Q3 on the next page is the code of a class named Circle. Study the code and implement the operator overloading for these relational operators ( , >=) for the Circle class. Then, write a test program that creates two instances of the Circle ..

  Have to implement a search algorithm

Suppose you have to implement a search algorithm in a high programming language such as Java or C++. You are given a linked list that is not sorted and it's rather small, in the order of a few dozen elements.

  Write a method in java that uses a switch statement

Write a method in JAVA that uses a switch statement and takes a person's age using an integer parameter , then checks if the age is valid (0-110), and then RETURNS a string based on the age

  Class pointparameters

What is the output of the following Java program? Explain in terms of how parameters are passed in Java.import java.awt.*;class PointParameters

  Videorental store operatorrecord clients

Project is to design a program to help a videorental store operatorrecord clients' transactions - Design a primitive database indicating

  Write a program that allows a user to enter a line of text

Write a program that allows a user to enter a line of text, counts number of words and number of vowels in the sentence, and gives the average number of vowels per word in the message

  Develop class which implements interface

Let the ADT called SquareMatrix. (The matrix can be represented by 2-D array of ints w/ n rows and n columns.) Write specification for ADT as Java interface. Develop the class which implements interface.

  Program that uses a library database of books

Write a Java program that uses a library database of books and patron data, as described in Exercise R22.2. Patrons should be able to check out and return books.

  Ticketmaster

TICKETMASTER - this class will have: a service charge = $8.00 per ticket, tax = .085 current amount of all tickets sold. Its responsibilities are printing a list of events for sale, looking up an event for a customer, and selling a ticket to the e..

  The data-centric java agricultural image storing application

Develop and test a specified a data-centric Java application. The required application is described in the Agricultural Image storing application- case-study

  Prevent clear communication

Conversational implicature always prevents clear communication - Describe a situation where communication between you and a co-worker

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