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

I need help making this program run. I have everything thats needed just need he

ID: 3759495 • Letter: I

Question

I need help making this program run. I have everything thats needed just need help finishing it.

//Math Tutor

#include <iostream>

#include<ctime>

#include<cstdlib>

using namespace std;

void getProbsPerSet(int&);

void doOneSet(char,int,int&);

void getMaxNum (int&);

void doOneProblem(char,int&,int&);

void generateOperands (int&,int&,int&);

void printHeader ();

void calcCorrectAnswer(char,int,int,int&);

void checkAnswer(int,int,int&);

void printReport (int,int,int,int);

int main()

{

  

int probperset;

int set1Correct,set2Correct,set3Correct;

srand(time(0));

getProbsPerSet(probperset);

doOneSet('+',probperset,set1Correct);

doOneSet('-',probperset,set2Correct);

doOneSet('*',probperset,set3Correct);

  

  

  

  

  

  

return 0;

}

void printHeader ()

{

cout << endl;

cout << "Set 1" << endl;

cout << "---------" << endl << endl;

  

  

}

void getMaxNum (int& max)

{

  

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

cin >> max;

cout << endl;

  

  

}

void doOneSet (char problemType, int numProbs, int& numCorrect)

{

printHeader ();

int maxNum;

int randomOne = 0;

int randomTwo = 0;

getMaxNum (maxNum);

generateOperands (randomOne, randomTwo,maxNum);

  

  

for ( int counter = 1;counter <= numProbs; counter++)

{

generateOperands (randomOne, randomTwo,maxNum);

  

  

  

switch(problemType)

{

case '+' : doOneProblem(problemType,randomOne,randomTwo);

break;

case '-' : doOneProblem(problemType,randomOne,randomTwo);

break;

case '*' : doOneProblem(problemType,randomOne,randomTwo);

break;

default: cout << "INVALID DATA" << endl;;

break;

  

  

}

}

}

void doOneProblem (char problemType,int& randomOne, int& randomTwo)

{

switch(problemType)

{

  

case '+' : cout << randomOne << problemType << randomTwo << endl;

break;

case '-' : cout << randomOne << problemType << randomTwo << endl;

break;

case '*' : cout << randomOne << problemType << randomTwo << endl;

break;

default: cout << "INVALID DATA" << endl;;

break;

  

}

  

}

void getProbsPerSet (int& num_set)

{

cout << " Enter problems per set: ";

cin >> num_set;

cout << endl;

}

void generateOperands (int& randomOne,int& randomTwo,int& maxNum)

{

  

  

  

randomOne = (rand() % maxNum + 1);

  

  

randomTwo = (rand() % maxNum + 1);

  

  

  

}

void calcCorrectAnswer (char problemType,int num1,int num2,int& answer);

{

if(problemType=='+')

{

answer = num1 + num2;

  

}

  

else if(problemType=='-')

{

answer = num1 - num2;

}

else

answer = num1 * num2;

}

void checkAnswer(int answer,int useranswer,int& numcorrect);

{

if(useranswer == answer)

{ cout << "Correct" <<endl;

numcorrect++;

}

else

cout <<"Incorrect"<<endl;

  

}

  

void printReport (int,int,int,int);

  

  

Explanation / Answer

// I fixed some errors. Cannot do more without knowing what the program is doing. Please give the question statement.

#include <iostream>
#include <ctime>
#include <cstdlib>
using namespace std;

void getProbsPerSet(int*);
void doOneSet(char,int,int&);
void getMaxNum (int&);
void doOneProblem(char,int&,int&);
void generateOperands (int&,int&,int&);
void printHeader ();
void calcCorrectAnswer(char,int,int,int&);
void checkAnswer(int,int,int&);
void printReport (int,int,int,int);

int main()
{
  
   int probperset;
   int set1Correct,set2Correct,set3Correct;
   srand(time(0));
   getProbsPerSet(&probperset);
   doOneSet('+',probperset,set1Correct);
   doOneSet('-',probperset,set2Correct);
   doOneSet('*',probperset,set3Correct);
  
   return 0;
}
void printHeader ()
{
   cout << endl;
   cout << "Set 1" << endl;
   cout << "---------" << endl << endl;
  
}

void getMaxNum (int& max)
{
   cout << " What is the maximum number for this set? ";
   cin >> max;
   cout << endl;
}

void doOneSet (char problemType, int numProbs, int& numCorrect)
{
   printHeader ();
   int maxNum;
   int randomOne = 0;
   int randomTwo = 0;
   getMaxNum (maxNum);
   generateOperands (randomOne, randomTwo,maxNum);

   for ( int counter = 1;counter <= numProbs; counter++)
   {
       generateOperands (randomOne, randomTwo,maxNum);

       switch(problemType)
       {
           case '+' : doOneProblem(problemType,randomOne,randomTwo);
               break;
           case '-' : doOneProblem(problemType,randomOne,randomTwo);
               break;
           case '*' : doOneProblem(problemType,randomOne,randomTwo);
               break;
           default: cout << "INVALID DATA" << endl;;
               break;
              
              
       }
   }
}

void doOneProblem (char problemType,int& randomOne, int& randomTwo)
{
   switch(problemType)
   {
          
       case '+' : cout << randomOne << problemType << randomTwo << endl;
           break;
       case '-' : cout << randomOne << problemType << randomTwo << endl;
           break;
       case '*' : cout << randomOne << problemType << randomTwo << endl;
           break;
       default: cout << "INVALID DATA" << endl;;
           break;
          
   }
  
}

void getProbsPerSet (int* num_set)
{
   cout << " Enter problems per set: ";
   cin >> *num_set;
   cout << endl;
}

void generateOperands (int& randomOne,int& randomTwo,int& maxNum)
{
   randomOne = (rand() % maxNum + 1);
   randomTwo = (rand() % maxNum + 1);
  
}
void calcCorrectAnswer (char problemType,int num1,int num2,int& answer)
{
   if(problemType=='+')
   {
       answer = num1 + num2;
  
   }
  
   else if(problemType=='-')
   {
       answer = num1 - num2;
   }
   else
       answer = num1 * num2;
       }
void checkAnswer(int answer,int useranswer,int& numcorrect)
{
   if(useranswer == answer)
   {
       cout << "Correct" <<endl;
       numcorrect++;
   }
   else
       cout <<"Incorrect"<<endl;
  
}
  
void printReport (int,int,int,int);

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