0

I am getting one error in this assignent and I am trying to find how i can seperate the total number of problems correct for each operator. I also get an error message but i cannot use a global variable or it is a 0 on the assignment.

ERROR MESSAGE:

test_problem_set.cpp: In function ‘int main()’:

test_problem_set.cpp:122: error: ‘num_of_problems’ was not declared in this scope

```
//this program acts as a math tutor
#include <cstdlib>
#include <ctime>
#include <iostream>
using namespace std;
void getProbsperset(int num_of_problems);
void doOneset(char operators, int num_of_problems);
void printReport(int num_of_problems);
void printHeader(char operators);
void getMaxNum(int& range);
void doOneProblem(char operators, int num_of_problems);
void getNumbers(char operators, int range, int& term_1, int& term_2);
void calcCorrectAnswer(int term_1,int term_2, char operators, int& z);
void checkAnswer(int term_1, int term_12);
void getProbsperset()
{
int num_of_problems;
cout <<"Today You Will Be Doing a Problem Set of Addition, Subtraction, and Multiplication:";
cin >>num_of_problems;
}
void doOneset(char operators, int problems)
{
int range, a;
printHeader(operators);
getMaxNum (range);
for(a = 0; a < problems; a++)
{
doOneProblem(operators, range);}
}
void doOneProblem(char operators, int range)
{
int term_1, term_2;
getNumbers(operators, range, term_1, term_2);
checkAnswer(term_1, term_2);
}
void printHeader(char operators)
{
if (operators=='+')
{
cout <<"\nPROBLEM SET 1"
<<"---------------\n";
}
else if (operators=='-')
{
cout <<"\nPROBLEM SET 2"
<<"---------------\n";
}
else
{
cout <<"\nPROBLEM SET 3"
<<"---------------\n";
}
}
void getMaxNum(int& range)
{
cout <<"Please enter the maxium num_of_problems for operations:";
cin >>range;
cout <<endl;
}
//the fallow program creates a problem (well we hope it doesent actually)
void getNumbers(char operators, int range, int& term_1, int& term_2)
{
term_1=rand()%range;
term_2=rand()%range;// add num_of_problems data here!!
cout <<"\n" << term_1 <<operators <<term_2 <<"=";
}
//the fallowing program asks the user to input an answer and then checks that answer
void checkAnswer(int term_1, int term_2, char operators)
{
int answer;
int z;
cin >> answer;
calcCorrectAnswer(term_1,term_2,operators,z);
if (answer== z)
{ cout<<"\n Correct\n";
}
else
cout <<"\nInocrrect\n";
}
//this program calculates the correct answer
void calcCorrectAnswer(int term_1,int term_2, char operators, int& z)
{
if (operators=='+')
{z = term_1 + term_2;}
else if (operators=='-')
{z = term_1 - term_2;}
else
{z = term_1 * term_2;}
}
// the fallowing prints a report on how well the student did on the exame
void printReport(int num_of_problems)
{
float total;
total =num_of_problems*3;
cout <<"\nSet 1: you got " <<" out of " <<num_of_problems <<" for a " <<(num_of_problems*100) <<"%";
cout <<"\nSet 2: you got " <<" out of " <<num_of_problems <<" for a " <<(num_of_problems*100) <<"%";
cout <<"\nSet 3: you got " <<" out of " <<num_of_problems <<" for a " <<(num_of_problems*100) <<"%";
cout <<"\nOveral all you got " <<" out of " ;
cout <<num_of_problems*3 <<" for a " <<"%\n";
}
int main()
{
srand(time(0));
getProbsperset();
doOneset('+', num_of_problems);
doOneset('-',num_of_problems);
doOneset('*', num_of_problems);
printReport (num_of_problems);
system ("pause");
return 0;
}
```