CS1150 (Spring 2013): Programming Assignment 3

Loops


Instructions

  1. Implement the Monty Hall Problem as discussed in class. A screenshot of the code is here. You may type the code exactly as you see it, but ensure that you understand what I am doing (this is why I provide a screenshot rather than the actual source code). If you would like to implement the solution differently, you are more than welcome to.
  2. Surround the solution in a loop (of your choice) and replace the user inputs with either hard-coded inputs or random door choices. Make sure that you always choose to switch doors. Remove all of the print statements and replace the final ones (telling you if you won or lost) with increments to either a win or loss counter.
  3. Run the loop some large number of times (1000 or 10000 should be sufficient). Print the final totals in the wins and losses counters and show that switching causes you to win 66.67% of the time.

Deliverables

Print out your source code, as well as the total number of wins and losses and the percentages.