While loop

I am making a game for class and i need help with my while loop. I want the program to run a different loop when the value is 0. I have the code written how I think it should work but the first while loop reaches 1 it jumps down into the second while loop right away. for example: you have 3 rocket attacks so on the first turn you use 1 rocket attack so now you have 2 left. On your second turn you use your rockets again so now you have 1 left. On the next turn you use the rockets again so now you have 0 left but instead of ending your turn it runs the next while loop which asks you to input a different value.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
while (rocketa > 0)
{
    cout << "You Dealt " << rocketAtt << " damage to the computer using your   rockets\n";
    p2Health -= rocketAtt;
    cout << p1Health << "\n" << p2Health << endl << endl;
    rocketa--;
    break;
}

while (rocketa == 0)
{
					
 cout << "Please choose a different attack" << endl;
 cout << "1. Rockets: 0 left " << endl;
 cout << "2. Machine Gun: " << machineGun << " left " << endl;
 cout << "3. Swing your sword " << endl;
 cout << "Enter your attack: "; 
 cout << endl;
 cin >> b;
 cout << endl;

}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23

while (true)
{
	if (rocketa > 0)
	{
		cout << "You Dealt " << rocketAtt << " damage to the computer using your   rockets\n";
		p2Health -= rocketAtt;
		cout << p1Health << "\n" << p2Health << endl << endl;
		rocketa--;
	}
	else
	{
		cout << "Please choose a different attack" << endl;
		cout << "1. Rockets: 0 left " << endl;
		cout << "2. Machine Gun: " << machineGun << " left " << endl;
		cout << "3. Swing your sword " << endl;
		cout << "Enter your attack: ";
		cout << endl;
		cin >> b;
		cout << endl;
	}
}
Topic archived. No new replies allowed.