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

Mathtotor2.cpp (20 pts) Write a program that can be used as a math totor for a y

ID: 3833906 • Letter: M

Question

Mathtotor2.cpp (20 pts)

Write a program that can be used as a math totor for a young student. The program should display a menu allowing the user to select one of the four options: 1) Addition, 2) Subtraction, 3) Multiplication or 4) Quit. The program then displays two random numbers between 10 and 50 that will be calculated. After the user has finished the math problem, the program should display the menu again. This process must repeat until the user chooses to quit the program. If the user selects and item not on the menu, the program should print an error message and then display the menu again.

Guidelines:

Need the following preprocessors:

#include <iostream>

#include <iomanip>

#include <cstdlib>          

#include <ctime>             

#include <string>

Do

{

       Display menu and collect choice;

       switch statement

              {

                     Case 1

                     Case 2

                     Case 3

                     Case 4

              }

       If choice is 1 or 2 or 3

              Display the problem with the selected math operator as in the example below

                           num1

                          + num2

                          -------        

       If student answer is the same as the correct answer

              Send a message: Congratulations! That is right!

       Else

              Send a message: Sorry, the correct answer is “correct answer”

      

} while (choice!= 4);

End of program;

Sample runs:

      Menu

1. Addition problem

2. Subtraction problem

3. Multiplication problem

4. Quit this program

1

    10

+ 24

   ---

    34

Congratulations! That's right.

      Menu

1. Addition problem

2. Subtraction problem

3. Multiplication problem

4. Quit this program

2

    11

-   9

   ---

     2

Congratulations! That's right.

      Menu

1. Addition problem

2. Subtraction problem

3. Multiplication problem

4. Quit this program

3

    33

*   4

   ---

   122

Sorry, the correct answer is 132.

      Menu

1. Addition problem

2. Subtraction problem

3. Multiplication problem

4. Quit this program

4

Thank you for using Math Totor.

!!!!! Please use C++

Explanation / Answer

#include<conio.h>
#include<iostream.h>
#include<iomanip.h>
#include<process.h>
#include<string.h>
class Maths
{
public:int addition(int a,int b)
{
return (a+b);
}
public:int substraction(int a,int b)
{
return(a-b);
}
public:int multiplication(int a,int b)
{
return(a*b);
}
};
void main()
{
int choice,x,y,ans;
clrscr();
Maths m1;
do
{
cout<<"Menu"<<endl;
cout<<"1.Addition"<<endl;
cout<<"2.Substraction"<<endl;
cout<<"3.Multipliocation"<<endl;
cout<<"4.Quit"<<endl<<endl;
cout<<"Please Enter Your Choice"<<endl;
cin>>choice;
if(choice==4)
{
break;
}
cout<<"Enter Two numbers in between 10 and 50"<<endl;
cin>>x>>y;
switch(choice)
{
case 1:ans=m1.addition(x,y);
   cout<<setw(4)<<x<<endl;
   cout<<"+"<<setw(3)<<y<<endl;

cout<<"-----"<<endl<<setw(4)<<ans<<endl;
cout<<"Congratualation!! That's right"<<endl<<endl;
break;
case 2: ans=m1.substraction(x,y);
   cout<<setw(4)<<x<<endl;
   cout<<"-"<<setw(3)<<y<<endl;
   cout<<"-----"<<endl<<setw(4)<<ans<<endl;
   cout<<"Congratualation!! That's right"<<endl<<endl;
break;
case 3:ans=m1.multiplication(x,y);
   cout<<setw(4)<<x<<endl;
   cout<<"*"<<setw(3)<<y<<endl;
   cout<<"-----"<<endl<<setw(4)<<ans<<endl;
   cout<<"Congratualation!! That's right"<<endl<<endl;
break;
default:if(choice!=4)
   {
   cout<<"Error!!Please Enter Valid Case"<<endl<<endl;
   }
}
}while(choice!=4);
cout<<"Thank You for using Maths Totor"<<endl;
getch();
}