Help with do-while loop

So i'm working on a program to play a simple blacjack game but I cant get this loop to work correctly so that the player can properly choose to hit or stop while playing. The way it is right now the loop will only end if the player_total is over 21 and the player says stop rather than it stopping when a player says stop or when the total goes over 21

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
  do
	{
		cout << "Hit or Stop?";
		cin >> opt2;

			if (opt2 == "Hit" || opt2 == "hit")
			{
			hit = 1 + rand() % 13;
				
				switch (hit)
				{
				case 1:
				cout << "Would you like the Ace to be 1 or 11?";
				cin >> value;
				hit = value;
				cout << "A ("<< value << ")\n";
				break;
				
				case 11: 
				hit = 10;
				cout << "J\n";
			        break;
					
				case 12: 
				hit = 10;
				cout << "Q\n";
				break;
					
				case 13:
				hit = 10;
				cout << "K\n";
				break;
					
				default:
				cout << hit << endl;
				break;
			}
					
				player_total = hit + player_total;
			}
				
			}
		while (player_total <= 21 or opt2 == "Hit" || opt2 == "hit");
The loop condition should probably be something like
while (player_total <= 21 && (opt2 == "Hit" || opt2 == "hit"));
The reason being that you want to continue only as long as the player's total is under 21 and the player chooses to hit.
ahhh thanks that helps a lot.
Topic archived. No new replies allowed.