Starting from:

$25

CECS282 - Homework 1 - Solved

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 otherdoor. 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.

More products