Ammora Aleisa

Ammora Aleisa

  • NA
  • 5
  • 3.9k

How to solve this program in Linux with C++? "Program is Game Show Simulation"

Feb 19 2011 11:39 PM
Hey guys,

I'm beginner in programming. I've tried to solve this program in Linux with C++ but it tells me there're more one errors!!

The program is about creating a Game Show Simulation, this is the description of it:

Write a program that will simulate the following situation 10,000 times so we can decide the answer to:

Suppose you're on a game show, and you're given the choice of three doors: Behind one door is a car; behind the others, goats. You pick a door, say No. 1, and the host, who knows what's behind the doors, opens another door, say No. 3, which he knows has a goat. He then says to you, "Do you want to pick door No. 2?" Is it to your advantage to switch your choice?

The pseudocode for this assignment would be:

Run a loop 10,000 times that:

  • Randomly picks a door that is the "prize door"
  • Randomly picks a door that is the "first choice"
  • Removes one of the doors that is both not the "prize door" nor the "first choice"
  • Randomly picks one of the remaining doors as your "second choice"
  • Compares the "prize door" to the "first choice" and "second choice" and saves it

After the loop is done, output a message that tells how many times the "prize door" was the "first choice" and how many times the "prize door" was the "second choice" so we can know what is the best choice.

The output of the homework should look like:

Number of times staying was the correct strategy: [NUMBER]
Number of times switching was the correct strategy: [NUMBER]
Therefore, the best thing to do is to [STRATEGY].


Answers (4)