Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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;

}image text in transcribed

Your main function for phase VI must look like this (you may add variable declarations and arguments only): int main) int probsPerSet; int setiCorrect, set2Correct, set3Correct srand (time(0)); getProbsPerSet () dooneSet (no-more-than-3-arguments>) doOneSet ); doOneSet ); printReport () Please note that you may send no more than 3 arguments to doOneSet. Hint: Although main will need three separate variables to keep track of the number of problems answered correctly in each set, your doOneSet function will have only one parameter which keeps track of the number of problems answered correctly in the current set. It will be up to main to get that information into the correct variable. The following structure diagram includes every function that you will have in your program. You should have no more and no fewer, and you should use the names that have been suggested here. Functions pictured below that are not labeled with a phase should be implemented at least by phase III. Please also read the notes below the structure diagram very carefully<>

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Practical Azure SQL Database For Modern Developers Building Applications In The Microsoft Cloud

Authors: Davide Mauri, Silvano Coriani, Anna Hoffma, Sanjay Mishra, Jovan Popovic

1st Edition

1484263693, 978-1484263693

More Books

Students also viewed these Databases questions

Question

=+ Are unions company-wide, regional, or national?

Answered: 1 week ago