Isolating the bug.

Can someone please isolate the problem? It says "expected primary parameters before 'else'. Thanks!

1
2
3
4
5
6
7
8
9
10
11
12
13
 if (choice == "1")
{if (weapon== true)
{if (chance == 3)
{cout << "MISS!";}
else if(chance == 5) 
{cout <<"\nCRITICAL HIT!";
goonhp -= (damage * 2);}

else{goonhp -= damage;} 
} else {if (chance == 3 || chance == 6) {cout << "\nMISS!";} else if (chance == 5) {goonhp -= (damage*2);} else {goonhp -= damage;}
}
else{bool dodge=true;}
If you would use a decent indentation style the problem would probably be easy to spot.

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
   if (choice == "1")
    {
        if (weapon== true)
        {
            if (chance == 3)
            {
                cout << "MISS!";
            }
            else if(chance == 5)
            {
                cout <<"\nCRITICAL HIT!";
                goonhp -= (damage * 2);
            }

            else
            {
                goonhp -= damage;
            }
        }
        else
        {
            if (chance == 3 || chance == 6)
            {
                cout << "\nMISS!";
            }
            else if (chance == 5)
            {
                goonhp -= (damage*2);
            }
            else
            {
                goonhp -= damage;
            }
        }
        else
        {
            bool dodge=true;
        }
You mean write clean code, right? K! Will surely work on that!
Topic archived. No new replies allowed.