Sale!

Homework 1: The Price is Wrong

$30.00

Category:
Rate this product

Homework 1:
The Price is Wrong

Overview
In this homework, you will implement a famous (but simple) game called the ?Monty Hall problem,? from
the television show Let’s Make a Deal. The game involves the following situation: the game host shows
the player three doors, numbered 1 through 3, and tells the player that behind only one of the doors lies a
great prize; the other two doors have goats behind them. The player picks one door, and in response the
host opens another door that he/she knows has a goat behind it. The host then asks the player if he/she
would like to switch to the other unopened door. After this decision, the player opens their door and claims
whatever lies behind it, be it goat or glorious prize.
Game Rules
1. A door is chosen in secret (1, 2, or 3) to be the ?winning? door. Implicitly, the other doors have goats.
2. The user is asked to choose a door (1, 2, or 3). You do not need to verify their choice.
3. Another door is chosen to reveal to the player. The chosen door must have a goat behind it, and
must not be the door that the player chose.
4. After revealing the door, the user is asked if they would like to switch to the only remaining other
door. Their response will be a ‘y’ or ‘n’, inputted as a char variable.
5. Reveal whether the user won the game or not by comparing their ?nal door choice to the secretly-chosen
winning door.
(a) If the user loses, give them a sad message.
(b) If the user wins, randomly choose one of ?ve glorious prizes of your design. Randomly pick one
of the ?ve prizes and output a description of the prize.
Requirements
Your lab must follow these code requirements:
• I recommend not using string variables, since they don’t behave exactly the same as in Java and
we haven’t covered them yet. If you ignore this advice, at least make sure you #include <string.
• You must generate random numbers using the <random library’s default_random_engine class, as
shown in lecture. I don’t care if your friend says you should do it another way.
Deliverables
Turn in the following when the homework is due:
1. A printed copy of your code, printed from your IDE when possible. If you cannot print from
your editor, copy your code into Notepad or another program with a ?xed-width (monospace) font and
print from there.
2. A printout of your program’s output showing four di?erent runs through the program:
(a) a run where the user does not switch and wins;
(b) a run where the user switches and wins;
1
(c) a run where the user does not switch and loses;
(d) a run where the user switches and loses.
2

Open chat
Need help?
Hello
Can we help you?