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

Ok guys, I need to write a Math Tutor program. I need to do it in 6 phases, I al

ID: 647706 • Letter: O

Question

Ok guys, I need to write a Math Tutor program. I need to do it in 6 phases, I already did three. I would appreciate any help with the next three.

Here is my code for the first three phases.

#include<iostream>
#include<ctime>
#include<cstdlib>

using namespace std;

void doOneSet (char);
int main()
{
srand(time(0));
doOneSet('+');
doOneSet('-');
doOneSet('*');
return 0;
}

void doOneSet (char problemType)
{
int num1=0,num2=0, maxNum=100;
int correctAnswer=0,userInput=0;
bool isCorrect=false;

switch(problemType)
{
case '+': for (int count=1;count<=5;count++)
{


num1=rand()%(maxNum+1);
num2=rand()%(maxNum+1);

cout<<num1<<" + "<<num2<<" = ";
cin>>userInput;
correctAnswer=num1+num2;

if(userInput==correctAnswer)
isCorrect=true;
else
isCorrect=false;
if(isCorrect)
cout<<"correct"<<endl;
else
cout<<"incorrect"<<endl;

} break;


case '-':for (int count=1;count<=5;count++)

{

num1=rand()%(maxNum+1);
num2=rand()%(maxNum+1);

cout<<num1<<" - "<<num2<<" = ";
cin>>userInput;
correctAnswer=num1-num2;

if(userInput==correctAnswer)
isCorrect=true;
else
isCorrect=false;
if(isCorrect)
cout<<"correct"<<endl;
else
cout<<"incorrect"<<endl;
}
break;

case '*':for (int count=1;count<=5;count++)
{
num1=rand()%(maxNum+1);
num2=rand()%(maxNum+1);

cout<<num1<<" * "<<num2<<" = ";
cin>>userInput;
correctAnswer=num1*num2;

if(userInput==correctAnswer)
isCorrect=true;
else
isCorrect=false;
if(isCorrect)
cout<<"correct"<<endl;
else
cout<<"incorrect"<<endl;
}
break;

}
}

and the next phases ask:

Phase IV: Now you are ready to let the user specify how many problems per set. However, due to certain new software use guidelines the user is allowed between 3 to 10 problems per set per run of the program.   (Recall that a set is a group of problems all of the same type. In this program we are doing three sets: one set of addition, one set of subtraction, and one set of multiplication. This means that, for example, if the problems per set is 7, there will be a total of 21 problems given.) As per the new guidelines, ask the user to enter only the acceptable number of problems per set at the very beginning of the program, so that all three sets have the same number of problems per set. Now your main function will look exactly like this (you may add variable declarations only):

For this phase you should also add a header at the beginning of each set, as illustrated in the following sample output for this phase. For purposes of the header, you should assume that the addition problems will always be set #1, the subtraction problems set #2, and the multiplication problems set #3.

Phase V: Now let the user specify maxNum, the maximum number to be used for each set. This means that instead of choosing numbers between 0 and 100 (inclusive) for each problem, the computer will be choosing numbers between 0 and maxNum(inclusive). You must allow the user to enter a different maximum number for each set. This won't change the main function, since you need to ask it again before each set. It will be done near the beginning of your doOneSet function. Here's the sample screen output:

Phase VI: Now you need to keep track of how the user is doing. At the end of the program, write a report which says how many the user got right on each set out of how many and for what percent. Also tell the overall figures. Here's the sample screen output:

Your main function for phase VI must look like this (you may add variable declarations and arguments only):

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.

Notes:

Note: The doOneProblem function does exactly one problem, not one *type* of problem!!

Please change getNumbers to generateOperands

CheckAnswer is the function that writes either "correct" or "incorrect"

You will receive a 0 on this assignment if you use global variables, arrays or structs

Turn in only phase VI, your final product. Provide sample output.

You will lose points if the code you put in one of your functions does not correspond to the name of the function given in the structure diagram.

  int main()     {         int probsPerSet;          srand(time(0));          getProbsPerSet(probsPerSet);            doOneSet('+', probsPerSet);             doOneSet('-', probsPerSet);         doOneSet('*', probsPerSet);     } 

Explanation / Answer

#include<iostream>
#include<ctime>
#include<cstdlib>

using namespace std;
void getProbsPerSet(int &);
void printReport(int, int, int, int);
void doOneSet(char, int, int&);
int main()
{
   int probsPerSet;
   int set1Correct, set2Correct, set3Correct;
   srand(time(0));
   int nset;
   getProbsPerSet(probsPerSet);
   doOneSet('+', probsPerSet, set1Correct);
   doOneSet('-', probsPerSet, set2Correct);
   doOneSet('*', probsPerSet, set3Correct);
   printReport(probsPerSet, set1Correct, set2Correct, set3Correct);
   return 0;
}

void getProbsPerSet(int &nset){
   cout << "Enter problems per set: ";
   cin >> nset;
}

void printReport(int nset, int set1Correct, int set2Correct, int set3Correct){
   int total = set1Correct + set2Correct + set3Correct;
   cout << "Set#1: You got " << set1Correct << " correct out of " << nset << " for " << (set1Correct * 100 / (nset)) << "%" << endl;
   cout << "Set#2: You got " << set2Correct << " correct out of " << nset << " for " << (set2Correct * 100 / (nset)) << "%" << endl;
   cout << "Set#3: You got " << set3Correct << " correct out of " << nset << " for " << (set3Correct * 100 / (nset)) << "%" << endl;
   cout << "Overall you got " << total << " correct out of " << nset * 3 << " for " << ((total * 100 / (3 * nset))) << "%" << endl;
}

void doOneSet(char problemType, int nset, int &correct)
{
   correct = 0;
   int num1 = 0, num2 = 0, maxNum = 100;
   int correctAnswer = 0, userInput = 0;
   bool isCorrect = false;

   switch (problemType)
   {
   case '+':
       cout << endl << " Set #1" << endl;
       cout << "-------" << endl << endl;
       cout << "What is the maximum number for this set? ";
       cin >> maxNum;
       cout << endl;
   for (int count = 1; count <= nset; count++)
   {


                   num1 = rand() % (maxNum + 1);
                   num2 = rand() % (maxNum + 1);

                   cout << num1 << " + " << num2 << " = ";
                   cin >> userInput;
                   correctAnswer = num1 + num2;

                   if (userInput == correctAnswer)
                       isCorrect = true;
                   else
                       isCorrect = false;
                   if (isCorrect){
                       cout << "correct" << endl;
                       correct++;
                   }
                   else
                       cout << "incorrect" << endl;

   }                           break;

   case '-':
       cout << endl << " Set #2" << endl;
       cout << "-------" << endl << endl;
       cout << "What is the maximum number for this set? ";
       cin >> maxNum;
       cout << endl;
       for (int count = 1; count <= nset; count++)

   {

               num1 = rand() % (maxNum + 1);
               num2 = rand() % (maxNum + 1);

               cout << num1 << " - " << num2 << " = ";
               cin >> userInput;
               correctAnswer = num1 - num2;

               if (userInput == correctAnswer)
                   isCorrect = true;
               else
                   isCorrect = false;
               if (isCorrect){
                   cout << "correct" << endl;
                   correct++;
               }
               else
                   cout << "incorrect" << endl;
   }
           break;

   case '*':
       cout << endl << " Set #3" << endl;
       cout << "-------" << endl << endl;
       cout << "What is the maximum number for this set? ";
       cin >> maxNum;
       cout << endl;
       for (int count = 1; count <= nset; count++)
   {
               num1 = rand() % (maxNum + 1);
               num2 = rand() % (maxNum + 1);

               cout << num1 << " * " << num2 << " = ";
               cin >> userInput;
               correctAnswer = num1*num2;

               if (userInput == correctAnswer)
                   isCorrect = true;
               else
                   isCorrect = false;
               if (isCorrect){
                   cout << "correct" << endl;
                   correct++;
               }
               else
                   cout << "incorrect" << endl;
   }
           break;
          
   }
}

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