Question
Hi. I have a code I wrote and I dont know how to do this last phase part and what it means. Below is my
Hi. I have a code I wrote and I dont know how to do this last phase part and what it means. Below is my code and attached is the instructions.
#include
#include
using namespace std;
void doOneSet(char,int,int&);
bool doOneProblem(char,int);
void generateOperands(int&,int&,int);
int calculateCorrectAnswer(int,int,char);
bool checkAnswer(int,int);
void getProbsPerSet(int&);
void printHeader(char);
int getMaxNum();
void printReport(int,int,int,int);
int main()
{int probsPerSet,correctAdd=0,correctSub=0,correctMult=0;
srand(time(0));
getProbsPerSet(probsPerSet);
doOneSet('+', probsPerSet,correctAdd);
doOneSet('-', probsPerSet,correctSub);
doOneSet('*', probsPerSet,correctMult);
printReport(probsPerSet,correctAdd,correctSub,correctMult);
system("pause");
}
void printReport(int set,int add,int sub,int mult)
{
cout
cout
cout
}
void printHeader(char op)
{int set = 0;
switch(op)
{{case '+': set=1; break;
case '-': set=2; break;
case '*': set=3; break;
}
}
cout
}
int getMaxNum()
{int max;
cout
cin>>max;
return max;
}
void doOneSet(char op,int n,int& correct)
{int i,max;
printHeader(op);
max=getMaxNum();
for(i=0;i if(doOneProblem(op,max)) correct++; } bool doOneProblem(char op,int max) {int ans,user,op1,op2; generateOperands(op1,op2,max); ans=calculateCorrectAnswer(op1,op2,op); cout cin>>user; if(checkAnswer(ans,user)) return true; else return false; } void generateOperands(int& op1,int& op2,int max) {op1=rand()%(max+1); op2=rand()%(max+1); } int calculateCorrectAnswer(int op1,int op2,char op) {switch(op) {case '+': return op1+op2; case '-': return op1-op2; default: return op1*op2; } } bool checkAnswer(int ans,int user) {if(ans==user) {cout return true; } else { cout return false; } } void getProbsPerSet(int& probsPerSet) {cout cin>>probsPerSet; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started