Problems about running the user-defined times of programs

Hi folks,

I'm doing some program about the craps game(rolling dice)
and it seems just confusing that whenever I prompt the user for input of the number of times of the crap games they want to play. The program will always run at the first choice that I give(see below). Is something about syntax or some hidden magic going wrong? I'm exhausted as a beginner...

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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
 #include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;

unsigned int rollDice(); // function prototype  

int main()
{
	int selection;
	cout << "Please make your selection: " << endl;
	cout << "1). Play 1,000 craps games." << endl;
	cout << "2). Play your own modified times of craps games."<< endl;
	cout << "3). Show answers to \n    What are the chances of winning at craps?\n"
		 << "    Do the chances of winning improve with the length of the game?" << endl;
	cout << "4). Exit." << endl;
	cin >> selection;
	
	if (selection = 1)
	{
		for (int x = 0; x < 1000; x++)
		{
			enum Status { CONTINUE, WON, LOST };
			unsigned int myPoint = 0;
			Status gameStatus = CONTINUE;
			unsigned int sumOfDice = rollDice();

			switch (sumOfDice)
			{
				case 7:
				case 11:
					gameStatus = WON;
					break;
				case 2:
				case 3:
				case 12:
					gameStatus = LOST;
					break;
				default:
					gameStatus = CONTINUE;
					myPoint = sumOfDice;
					cout << "Point is " << myPoint << endl;
					break;
			}

			while (CONTINUE == gameStatus)
			{
				sumOfDice = rollDice();

				if (sumOfDice == myPoint)
					gameStatus = WON;
				else
					if (sumOfDice == 7)
						gameStatus = LOST;
			}

			if (WON == gameStatus)
				cout << "Player Wins!!!" << endl;
			else
				cout << "Player Loses..." << endl;
		}
	}
	
	if (selection = 2)
	{
		int fnum;
		cout << "Choose the times that you want the game to be played: " << endl;
		cin >> fnum;
		for (int x = 0; x < fnum; x++)
		{
			enum Status { CONTINUE, WON, LOST };
			unsigned int myPoint = 0;
			Status gameStatus = CONTINUE;
			unsigned int sumOfDice = rollDice();

			switch (sumOfDice)
			{
			case 7:
			case 11:
				gameStatus = WON;
				break;
			case 2:
			case 3:
			case 12:
				gameStatus = LOST;
				break;
			default:
				gameStatus = CONTINUE;
				myPoint = sumOfDice;
				cout << "Point is " << myPoint << endl;
				break;
			}

			while (CONTINUE == gameStatus)
			{
				sumOfDice = rollDice();

				if (sumOfDice == myPoint)
					gameStatus = WON;
				else
					if (sumOfDice == 7)
						gameStatus = LOST;
			}

			if (WON == gameStatus)
				cout << "Player Wins!!!" << endl;
			else
				cout << "Player Loses..." << endl;
		}
	}
	//if (selection = num3)
	//
	//if (selection = num4)
	//
	
	/*enum Status { CONTINUE, WON, LOST };

	srand(static_cast<unsigned int>(time(0)));

	unsigned int myPoint = 0;
	Status gameStatus = CONTINUE;
	unsigned int sumOfDice = rollDice();

	switch (sumOfDice)
	{
		case 7:
		case 11:
			gameStatus = WON;
			break;
		case 2:
		case 3:
		case 12:
			gameStatus = LOST;
			break;
		default:
			gameStatus = CONTINUE;
			myPoint = sumOfDice;
			cout << "Point is " << myPoint << endl;
			break;
	}

	while (CONTINUE == gameStatus)
	{
		sumOfDice = rollDice();

		if (sumOfDice == myPoint)
			gameStatus = WON;
		else
			if (sumOfDice == 7)
				gameStatus = LOST;
	}

	if (WON == gameStatus)
		cout << "Player Wins!!!" << endl;
	else
		cout << "Player Loses..." << endl;
		*/
	getchar();
	getchar();
	getchar();
}

unsigned int rollDice()
{
	unsigned int die1 = 1 + rand() % 6;
	unsigned int die2 = 1 + rand() % 6;

	unsigned int sum = die1 + die2;

	cout << "Players Rolled " << die1 << " + " << die2 << " = " << sum << endl;
	return sum;
}

so after the if selection = 2; the program will run 1000 times first and then ask for the number. Can anybody help... This may just too easy for you guys but I'm now in no mood of...solving it...
note that when I tried to set the first if condition as comments and run the program. It is doing fine. It will go straight and ask you about the input. What the hell is wrong...
No I see what is going on now.... I used = instead of == to set the equality check...
Topic archived. No new replies allowed.