Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hi. I have a code I wrote and I dont know how to do this last phase part and wha

ID: 3917205 • Letter: H

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 code and attached is the instructions.

#include <iostream>

#include <ctime>

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<<"Set # 1: You got "<<add<<" out of "<<set<<" for "<<(int)(add/(double)set*100.)<<"% ";

cout<<"Set # 2: You got "<<sub<<" out of "<<set<<" for "<<(int)(sub/(double)set*100.)<<"% ";

cout<<"Set # 3: You got "<<mult<<" out of "<<set<<" for "<<(int)(mult/(double)set*100.)<<"% ";

}

void printHeader(char op)

{int set = 0;

switch(op)

{{case '+': set=1; break;

case '-': set=2; break;

case '*': set=3; break;

}

}

cout<<"Set # "<<set<<" ------- ";

}

int getMaxNum()

{int max;

cout<<"What is the maximum number for this set? ";

cin>>max;

return max;

}

void doOneSet(char op,int n,int& correct)

{int i,max;

printHeader(op);

max=getMaxNum();

for(i=0;i<n;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<<op1<<" "<<op<<" "<<op2<<" = ";

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<<"correct ";

return true;

}

else

{ cout<<"incorrect ";

return false;

}

}

void getProbsPerSet(int& probsPerSet)

{cout<<"Enter problems per set: ";

cin>>probsPerSet;

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

Explanation / Answer

#include<iostream>

#include<stdio.h>

#include<stdlib.h>

#include<time.h>

using namespace std;

void getProbsPerSet(int&);

void doOneSet(char,int,int&);

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 getProbsPerSet(int& probsPerSet)

{

cout<<"Enter problems per set: ";

cin>>probsPerSet;

}

void doOneSet(char op,int n,int& correct)

{

int i,max,set,ans,user,op1,op2;

switch(op)

{

{

case '+': set=1; break;

case '-': set=2; break;

case '*': set=3; break;

}

}

cout<<"Set # "<<set<<" ------- ";

cout<<"What is the maximum number for this set? ";

cin>>max;

for(i=0;i<n;i++)

{

op1=rand()%(max+1);

op2=rand()%(max+1);

switch(op)

{

case '+': ans=op1+op2;

break;

case '-': ans=op1-op2;

break;

default: ans=op1*op2;

}

cout<<op1<<" "<<op<<" "<<op2<<" = ";

cin>>user;

if(ans==user)

{

cout<<"correct ";

correct++;

}

else

{

cout<<"Incorrect ";

}

}

}

void printReport(int set,int add,int sub,int mult)

{

cout<<"Set # 1: You got "<<add<<" out of "<<set<<" for "<<(int)(add/(double)set*100.)<<"% ";

cout<<"Set # 2: You got "<<sub<<" out of "<<set<<" for "<<(int)(sub/(double)set*100.)<<"% ";

cout<<"Set # 3: You got "<<mult<<" out of "<<set<<" for "<<(int)(mult/(double)set*100.)<<"% ";

}

you need to perform the work exactly by 3 functions printReport, doOneSet, and getProbsPerSet

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote