CSCI 200 - Spring 2026
Foundational Programming Concepts & Design

A1 - Let's Make A Deal

→This assignment is due by Tuesday, February 03, 2026, 11:59 PM.←
→ As with all assignments, this must be an individual effort and cannot be pair programmed. Any debugging assistance must follow the course collaboration policy and be cited in the comment header block for the assignment.←

Jump To: · Rubric · Submission ·


Assignment Code Starter


Make sure you have the appropriate comment header block at the top of every assignment from this point forward. The header block should include the following information at a minimum.

/* CSCI 200: Assignment 1: A1 - Let's Make A Deal
 *  * Author: XXXX (INSERT_NAME) * Resources used (Office Hours, Tutoring, Other Students, etc & in what capacity):  * // list here any outside assistance you used/received while following the * // CS@Mines Collaboration Policy and the Mines Academic Code of Honor *  * XXXXXXXX (MORE_COMPLETE_DESCRIPTION_HERE)  */ // The include section adds extra definitions from the C++ standard library. #include <iostream> // For cin, cout, etc. // We will (most of the time) use the standard library namespace in our programs. using namespace std; // Define any constants below this comment. // Must have a function named "main", which is the starting point of a C++ program. int main() { /******** INSERT YOUR CODE BELOW HERE ********/ cout << "Hello world!" << endl; // print Hello world! to the screen /******** INSERT YOUR CODE ABOVE HERE ********/ return 0; // signals the operating system that our program ended OK. }

Find the Car!


Your goal for this assignment is to simulate the classic Monty Hall Problem and prove it's better to always switch doors. You'll start out by implementing a human playable version and then simulate many trials to confirm the statistics. Your program will validate the user input and ensure all rules are properly followed.

Secretly Place the Car

In the Monty Hall Problem, a contestant is faced with three closed doors. Behind one of the doors is a car and behind the other two are goats. The contestant will choose a door. Then Monty will open a door to reveal a goat and ask "Do you want to change your guess to the other door?" The contestant makes their decision and their door is opened, revealing their prize.

We will assign the doors numbers 1, 2, and 3. The first step is to randomly choose which door the car is behind. Be sure to use the Mersenne Twister generator to generate a valid value. As a temporary testing step, you may wish to print this to the terminal to verify your program is running correctly, but be sure to remove it later on.

Contestant - Choose a Door

The next step is to ask the user which door they'd like to select. At this point, your program should look as follows:

Choose a door 1, 2, or 3: 2

We will assume (for the moment) we have a smart user that will follow instructions and enter the expected inputs. That is, they will pick door 1, 2, or 3.

Monty - Open a Door

Now it's time for Monty to reveal a goat. After the contestant has chosen their door, there's two possible scenarios:

  1. The contestant has chosen a goat. The other two doors contain the car and a goat. Open the door with the goat.
  2. The contestant has chosen the car and the two remaining doors contain goats. Randomly choose either one to open.

Print to the user which door is being opened and what's behind it. Your program should ALWAYS reveal a goat. At this point, our program flow is:

Choose a door 1, 2, or 3: 2
Door #1 contains a goat.

Contestant - Switch Doors?

At this point, the contestant needs to decide if they want to switch doors. Prompt them to make their choice expecting a 'Y' or 'N' as their choice:

Choose a door 1, 2, or 3: 2
Door #1 contains a goat.
Do you wish to change doors, Y or N: Y

Monty - Did We Win?

Time for the big reveal! Tell the contestant what's behind their door and if they made the right choice. There are two ways the program could end at this point:

Choose a door 1, 2, or 3: 2
Door #1 contains a goat.
Do you wish to change doors, Y or N: Y
Behind your Door #3 is a CAR!
Good job switching doors!
Choose a door 1, 2, or 3: 2
Door #1 contains a goat.
Do you wish to change doors, Y or N: Y
Behind your Door #3 is a goat
You shouldn't have switched doors.
Choose a door 1, 2, or 3: 2
Door #1 contains a goat.
Do you wish to change doors, Y or N: N
Behind your Door #2 is a CAR!
Good job not switching doors.
Choose a door 1, 2, or 3: 2
Door #1 contains a goat.
Do you wish to change doors, Y or N: N
Behind your Door #2 is a goat
You should have switched doors.

Contestant - Play Again?

After the contestant sees their outcome, prompt them to play again or not. If they choose to play again, place the car behind a new random door. Continue this process until the user decides to stop.

Choose a door 1, 2, or 3: 2
Door #1 contains a goat.
Do you wish to change doors, Y or N: Y
Behind your Door #3 is a CAR!
Good job switching doors!
Do you wish to play again, Y or N: Y
Choose a door 1, 2, or 3: 1
Door #3 contains a goat.
Do you wish to change doors, Y or N: Y
Behind your Door #2 is a goat
You shouldn't have switched doors.
Do you wish to play again, Y or N: N

Validation Time

We are still assuming a smart user (if we ask for an integer, they'll give us an integer. If we ask for a character, they'll give us an expected character). But we are now going to ensure the user can't cheat at our game and can't break it.

Door Choice

Ensure the contestant chooses only Door 1, 2, or 3. If they enter anything else, then reprompt them to choose again.

Choose a door 1, 2, or 3: 6
Choose a door 1, 2, or 3: 9
Choose a door 1, 2, or 3: 0
Choose a door 1, 2, or 3: w
Choose a door 1, 2, or 3: 2
Door #3 contains a goat.
Do you wish to change doors, Y or N: 
Switch Doors? Play Again?

Ensure the contestant enters only Y or N or their lower case equivalents. If they enter anything else, then reprompt them to enter again.

Do you wish to change doors, Y or N: a
Do you wish to change doors, Y or N: 4
Do you wish to change doors, Y or N: l
Do you wish to change doors, Y or N: y
Behind your Door #1 is a goat
You shouldn't have switched doors.
Do you wish to play again, Y or N: k
Do you wish to play again, Y or N: K
Do you wish to play again, Y or N: n

The Simulator


How Many Trials To Run?

When the contestant has decided to quit playing, and they now wish to determine statistically if they should switch or not, begin the trials. Ask the user to enter a positive integer corresponding to the number of trials to run.

Do you wish to play again, Y or N: n
How many trials do you wish to run: 0
How many trials do you wish to run: -100
How many trials do you wish to run: 10

Run the Experiment

For each trial, we'll automate the game. Perform the following steps:

  1. Randomly place the car behind a door
  2. Randomly choose a door for the contestant
  3. Choose a door that would be opened corresponding to a goat
  4. If the contestant's door is the car, then increment a counter tracking the number of wins when the contestant stays on their door
  5. If the unopened door is the car, then increment a counter tracking the number of wins when the contestant switches their door

After all the trials have run, print out a summary of the number of wins each scenario had and the percentage of wins this corresponds to.

Do you wish to play again, Y or N: n
How many trials do you wish to run: 27
27 Trials:
Stay:   6       22.2222%
Switch: 21      77.7778%

Reflection question: How many trials do you need to simulate to accurately verify the expected value?


Grading Rubric


As this is an introductory C++ course that teaches the fundamental concepts of the language and implementation details of each algorithm, the use of the C++ algorithm library, lambda functions, structured bindings, and smart pointers are prohibited. The use of auto is also discouraged to be aware of the explicit type of every variable used throughout your program.

Your submission will be graded according to the following rubric:

PointsRequirement Description
0.5Submitted correctly by Tuesday, February 03, 2026, 11:59 PM
0.5Project builds without errors nor warnings.
2.0Best Practices and Style Guide followed.
0.5Program follows specified user I/O flow.
0.5Public and private tests successfully passed.
2.0Fully meets specifications.
6.00Total Points


Submission


Always, always, ALWAYS update the header comments at the top of your main.cpp file. And if you ever get stuck, remember that there is LOTS of help available.

Zip together your main.cpp, Makefile files and name the zip file A1_USERNAME.zip where USERNAME is your user id. Upload this zip file to Canvas under A1.

After submitting to Canvas, download your submission to ensure your submission is correct and complete. Submissions that are empty or contain only the starter code will not be considered.


→This assignment is due by Tuesday, February 03, 2026, 11:59 PM.←
→ As with all assignments, this must be an individual effort and cannot be pair programmed. Any debugging assistance must follow the course collaboration policy and be cited in the comment header block for the assignment.←