Math Tutor help

Hello my fellow programmers, I am in need of assistance. I have mostly completed my code in regards to the program I have to make, called "Math Tutor". I pretty much done most of it, but my main problem is that I need the amount of "correct" and "incorrect" is my main issue. I tried everything and I am still having trouble on it. Any help is appreciated. For example:

I try to punch in numbers in the calculator, and let's see I did 7 attempts. After I put "5" which is the message "Quit" it will tell me:

7 Attempts
4 Correct
3 Incorrect

Something like this, I did the Attempt part correct, but the Correct and Incorrect is my main issue. Thank you so much for helping.

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

using namespace std;

int main()

{

	double randNum1, randNum2;
	int userTotal, computerTotal, computerTotal2, computerTotal3;
	int tries = 0;
	double computerTotal4;
	int seed = time(0);
	int userinput;
	srand(seed);
	randNum1 = 1 + rand() % 200;
	randNum2 = 1 + rand() % 200;
	computerTotal = randNum1 + randNum2;
	computerTotal2 = randNum1 - randNum2;
	computerTotal3 = randNum1 * randNum2;
	computerTotal4 = randNum1 / randNum2;


	cout << "======================" << endl;
	cout << "Welcome to Math Tutor!" << endl;
	cout << "======================" << endl;

	cout << endl;



	do
	{
		cout << "  1. Addition" << endl;
		cout << "  2. Subtraction" << endl;
		cout << "  3. Multiplication" << endl;
		cout << "  4. Division" << endl;
		cout << "  5. Quit" << endl;


		cout << "What type of problem would you like to try: ";
		cin >> userinput;
		++tries;




		if (userinput == 1)

		{
			cout << setw(5) << randNum1 << endl;
			cout << setw(2) << "+" << randNum2 << endl;
			cout << "-----\n";
			cin >> userTotal;

			if (userTotal == computerTotal)
				cout << "\Great Job!\n";
			else
				cout << "\nSorry, wrong answer. Correct answer is " << computerTotal << endl;
		}
		else if (userinput == 2)
		{
			cout << setw(5) << randNum1 << endl;
			cout << setw(2) << "-" << randNum2 << endl;
			cout << "-----\n";
			cin >> userTotal;

			if (userTotal == computerTotal2)
				cout << "\Great Job!\n";
			else
				cout << "\nSorry, wrong answer. Correct answer is " << computerTotal2 << endl;
		}
		else if (userinput == 3)
		{
			cout << setw(5) << randNum1 << endl;
			cout << setw(2) << "*" << randNum2 << endl;
			cout << "-----\n";
			cin >> userTotal;

			if (userTotal == computerTotal3)
				cout << "\Great Job!\n";
			else
				cout << "\nSorry, wrong answer. Correct answer is " << computerTotal3 << endl;
		}
		if (userinput == 4)
		{
			cout << setw(5) << randNum1 << endl;
			cout << setw(2) << "/" << randNum2 << endl;
			cout << "-----\n";
			cin >> userTotal;

			if (userTotal == computerTotal4)
				cout << "\Great job!\n";
			else
				cout << "\nSorry, wrong answer. Correct answer is " << computerTotal4 << endl;
		}

	} while (userinput != 5);
	cout << "Attempt" << tries << endl;
	cout << "Correct" << endl;
	cout << "Incorrect" << endl;
}
Similar to how you are counting 'tries', you need to declare and initialize to 0 'correct' and 'incorrect' count variables. Increment them within the appropriate if and else clauses.
Topic archived. No new replies allowed.