Sentinel, Query, and Looping Control: Can't Compile

I'm working on an assignment for my class, but I can not get this app to run, because there are errors. This is supposed to be a math "game" that the user inputs the # of problems that they want to solve, and the program presents them with the given amount.

Sentinel loops keep them doing the same problem until the user gets it correct, and it is supposed to keep track of how many attempts it takes to do all the problems in order to calculate an average. Once it gets out of the sentinel loop, I need it to calculate this, and then prompt the user whether they'd like to run the program again using a query control loop.

I keep getting an error on line 49/50 about missing closing brackets.

What am I doing incorrectly?

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
#include <iostream>
#include <ctime>

using namespace std;

int main()
{
	srand(time(0));
	
	int num1, num2;
	int quant;
	int guess, answ, attempts;
	double accuracy = (double) quant / attempts;
	char resp;
	
    do
    {
	
	    cout << "Welcome. How many multiplication problems would you like to do? ";
	    cin >> quant;
    
        {        
        
	    for(int prob = 0; prob < quant; prob++)	
	    
		num1 = rand() % 12 + 1;
		num2 = rand() % 12 + 1;
		answ = num1 * num2;
	
	            do
		        {
		        cout << num1 << " x " << num2 << " = ";
		        cin >> guess;
                attempts++;

	            } while (guess != answ);

	            cout << "Correct!" << endl;
        }    
                
        cout << "Great job! You finished all the problems." << endl;
        cout << "Problems: " << quant << "   Guesses: " << attempts << "   Average: " << accuracy << endl;
            cout << "Would you like to play again? Y/N " << endl;
            cin >> resp;
	
	} while (resp == 'Y' || resp == 'y');
	        
    }
    return 0;	
}


Thank you in advance!
1
2
3
        {        
        
	    for(int prob = 0; prob < quant; prob++)	


Should be :
1
2
 	    for(int prob = 0; prob < quant; prob++)
       {        
Ok, it's not giving me the compiling error now. Now it won't load. Is there still something that I'm doing wrong?
Still need help. This is due today, and I've been working and re-working this for three days. This is what I have now:

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
#include <iostream>
#include <ctime>

using namespace std;

int main()
{
	srand(time(0));
	
	int num1, num2;
	int quant, loops;
	int guess, answ, attempts;
	double accuracy = (double) quant / attempts;
	char resp;
	
    do //start program
    {
	
	    cout << "Welcome. How many multiplication problems would you like to do? ";
	    cin >> quant;    
        
	    for(int prob = 0; prob < quant; prob++)	//generate problems
	    {
		num1 = rand() % 12 + 1;
		num2 = rand() % 12 + 1;
		answ = num1 * num2;
	
	            do
		        {
		        cout << num1 << " x " << num2 << " = ";
		        cin >> guess;
                attempts++;

	            } while (guess != answ);

	            cout << "Correct!" << endl;
	            loops++;
        }    
                
    } while (loops < quant);
    
        cout << "Great job! You finished all the problems." << endl;
        cout << "Problems: " << quant << "   Guesses: " << attempts << "   Average: " << accuracy << endl;
            cout << "Would you like to play again? Y/N " << endl;
            cin >> resp;
	        
    } 
    
    return 0;	
}
.
Last edited on
To anyone who finds this thread, this was my problem:

I had an extra closing bracket on line 47. Deleting it solved my problem. Who knew? =)
Topic archived. No new replies allowed.