Help with Programming

Hi, how do i do this part of program?


I need my program to say this (below) however I am unsure as to how to do it. My code is written below I was hoping someone could assist me in making this change.

int main()
{
int probsPerSet;
int set1Correct,set2Correct, set3Correct;
srand(time(0));
getProbsPerSet(<arguments>);
doOneSet(<no-more-than-3-arguments>);
doOneSet(<no-more-than-3-arguments>);
doOneSet(<no-more-than-3-arguments>);
printReport(<arguments>);
}

MY CODE:


#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.)<<"%\n";
cout<<"Set # 2: You got "<<sub<<" out of "<<set<<" for "<<(int)(sub/(double)set*100.)<<"%\n";
cout<<"Set # 3: You got "<<mult<<" out of "<<set<<" for "<<(int)(mult/(double)set*100.)<<"%\n";
}
void printHeader(char op)
{int set = 0;
switch(op)
{{case '+': set=1; break;
case '-': set=2; break;
case '*': set=3; break;
}
}
cout<<"Set # "<<set<<"\n-------\n\n";
}
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\n";
return true;
}
else
{ cout<<"incorrect\n";
return false;
}
}
void getProbsPerSet(int& probsPerSet)
{cout<<"Enter problems per set: ";
cin>>probsPerSet;
}
Last edited on
how do i do this part of program?

Imagine that we've never met you, and have no idea at all what you're talking about. When you ask questions, keep that in mind.

What does your code do that you don't like, or what does it not do that you wish it did do?

Thanks! I am new to the forum, I updated my question.
your main looks like the example main. no, your question still does not make a lot of sense, to me it looks like you did it.

please wrap posted code in the <> tags from the editor.
I need my program to say this (below)


I don't see anything. Say what?
Topic archived. No new replies allowed.