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].
Ammora AleisaPosted Feb 21, 2011, 4:25 AM
Ok, so how about this:
# include
using namespace std;
int main()
{
int door1, door2, door3;
cin>> Pick a number;
cout<< "Number of times staying was the correct strategy:";
if (door1 = car)
{
cout << "Who knows what's behind the door?";
}
else (door2, door3 = ghost)
{
cout << "Do you want to pick door No.2?";
}
// loop-continuation, because in the question asks for run the loop 10,000
for (int counter = 1; counter <= 10; counter++)
cout << counter << " ";
cout << endl;
}
-----------------------------------
I'm not sure if I did in a right way cause he asks many things, I'm still confused. I guess I'll submit this one and he maybe give some credits. I've to do right now before I go to class today.
Sam HobbsPosted Feb 21, 2011, 2:59 AM
Note that you are not entering any data; you don't have a "cin" to read something from the console.
Try these. I will try to help after you have studied the above and fixed your code with this much.
Ammora AleisaPosted Feb 20, 2011, 11:18 PM
ok you're right. Actually I've bought the book for C++ and also I read many times but I can't understand very quick, especially when the instructor asks us to make the programs in limited time. I agree with you when you said none want to do others work and I won't be able to know it this way, but I hope I can get the from you at least help me to fix what I've done with this program:
#include
using namespace std;
int main()
{
int (door1, door2, door3)
cin>> Enter your door;
cout<<" This is your "" ";
if (door1 = car)
{
cout<<" This is the right door";
}
else (the door = ghost)
{
cout <<" This is not a right door";
if else
{
cout <<"This is not a right door" ;
}
Sam HobbsPosted Feb 20, 2011, 6:35 PM
If you have about $500 then you can post a message in the Paid Projects forum and maybe someone will do it for you but note that if your instructor asks you questions about the code and you have no idea how it works, then you might get a bad grade anyway.