1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
|
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <string>
using namespace std;
int main()
{
//declarations
int door1, door2, door3;
string doorPrize1, doorPrize2, doorPrize3;
int playersPick, doorOpen;
int userDecision;
//Greeting
cout << "Welcome to Let's Make You Rich\n";
cout << "To play this game we have randomly chosen the door which the prize is behind." << endl;
cout << "Your choices are Doors 1, 2, or 3.\n\n";
cout << "Do you want to take your chances at $1,000,000.00? \n";
cout << "Enter 1 for YES or 0 for NO. \n\n";
cin >> userDecision;
do
{
//Randomly place prizes behind the doors
switch (rand() % 6)
{
case 0: door1 = 1; door2 = 2; door3 = 3; break;
case 1: door1 = 1; door2 = 3; door3 = 2; break;
case 2: door1 = 2; door2 = 1; door3 = 3; break;
case 3: door1 = 2; door2 = 3; door3 = 1; break;
case 4: door1 = 3; door2 = 1; door3 = 2; break;
case 5: door1 = 3; door2 = 2; door3 = 1; break;
}//end switch
switch (door1)
{
case 1:
doorPrize1 = "!!!!!! YOU'VE JUST WON $1,000,000.00 !!!!!\n\n";
break;
case 2:
doorPrize2 = "!!!!!! YOU'VE JUST WON 10,000 RECYCLEABLE CANS !!!!!!\n\n";
break;
case 3:
doorPrize3 = "!!!!!! SORRY YOU'VE JUST LOST THE GAME !!!!!!\n\n";
break;
}//end switch
switch (door2)
{
case 1:
doorPrize1 = "!!!!!! YOU'VE JUST WON $1,000,000.00 !!!!!!\n\n";
break;
case 2:
doorPrize2 = "!!!!!! YOU'VE JUST WON 10,000 RECYCLEABLE CANS !!!!!!\n\n";
break;
case 3:
doorPrize3 = "!!!!!! SORRY YOU'VE JUST LOST THE GAME !!!!!!\n\n";
break;
}//end switch
switch (door3)
{
case 1:
doorPrize1 = "!!!!!! YOU'VE JUST WON $1,000,000.00 !!!!!!\n\n";
break;
case 2:
doorPrize2 = "!!!!!! YOU'VE JUST WON 10,000 RECYCLEABLE CANS !!!!!!\n\n";
break;
case 3:
doorPrize3 = "!!!!!! SORRY YOU'VE JUST LOST THE GAME !!!!!!\n\n";
break;
}//end switch
cout << "I have shuffled the prizes around and they have been randomly placed behind the doors.\n"
<< "Now all you have to do is choose the door that has the $1,000,000.00 behind it. \n"
<< "So quit stalling now, and choose your door.\n"
<< "Will it be Door Number 1, Door Number 2, or Door Number 3?\n"
<< "Please press the doors corresponding number. \n\n";
cin >> playersPick;
cout << "You chose Door Number " << playersPick << "\n";
do
{
doorOpen = rand() % 3 + 1;
} while (doorOpen == playersPick);
cout << "Now I will open Door Number " << doorOpen << "\n";
///////////////PROBLEM HERE///////////////////////
/* Need to find a way to associate doorOpen with corresponding door1, door2, door3 messages */
cout << "Now that we know what was behind Door Number " << doorOpen << " I have to ask you 1 more question. \n"
<< "Would you like to switch doors before we open your door?\n"
<< "Enter 1 for YES and 0 for NO \n";
cin >> userDecision;
cout << "Would you like to play again? Enter 1 for YES and 0 for NO.\n";
cin >> userDecision;
} while (userDecision == 1);
return 0;
}
|