Answer to Question #264690 in C++ for Qman

Question #264690
  • The program must start by calling a mainMenu() function that will display the following:

*Welcome to your arithmetic training. This program tests your skills with basic mathematical operations between two numbers. Please select one of the following actions:

1. Addition.

2. Subtraction

3. Multiplication

4. Module Operation.

5. Random Arithmetic operations.

6. Exit.

  • Requirements:

*Values to sum, module operations, and number difference values must be up to 2 digits

*For products one of the factors must be one digit and the other up to 2 digits

  • While inside a particular operation the user must have the option to continue more of the same operation or to get back to main menu. This requirement is voided when working inside the random operations. While inside a particular operation, statistic of the number of questions, right answers and wrong answers must be kept. When the user decides to go back to the main menu the program must display such statistic to the user and then go back to the main menu.
1
Expert's answer
2021-11-12T00:08:46-0500
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;


int main()
{
     int c,a,b,d,f;
    while(f=2){
      cout<<"**Welcome to your arithmetic training"<<endl;
    cout<<"This program test your skill with basic mathematics operations between two numbers"<<endl;
    cout<<"Please select one of the following actions: "<<endl;
    cout<<"\t\t1.Addition"<<endl;
    cout<<"\t\t2.Subtraction"<<endl;
    cout<<"\t\t3.Multiplication"<<endl;
    cout<<"\t\t4.Module Application"<<endl;
    cout<<"\t\t5.Random Arithmetic"<<endl;
    cout<<"\t\t6.Exit"<<endl;
    cin>>c;
    switch(c)
    {
    case 1:
        cout<<"\t\t*****Addition********"<<endl;
        cout<<"Enter the first operand and Second operand: "<<endl;
        cin>>a>>b;
        d=a+b;
        if(d>10 || d>99)
        {
         cout<<"Addition between two numbers is: "<<d<<endl;
        }
        cout<<"Would you like to continue 1 for YES or 2 Back To Main menu"<<endl;
        cin>>f;
        if(f=1)
        {
          cout<<"Enter the first operand and Second operand: "<<endl;
          cin>>a>>b;
          d=a+b;
          cout<<"Addition between two numbers is: "<<d<<endl;
        }
        break;
    case 2:
        cout<<"\t\t*****Subtraction********"<<endl;
        cout<<"Enter the first operand and Second operand: "<<endl;
        cin>>a>>b;
        d=a-b;
        if(d>10 || d>99)
        {
         cout<<"Subtraction between two numbers is: "<<d<<endl;
        }
        cout<<"Would you like to continue 1 for YES or 2 Back Main menu"<<endl;
        cin>>f;
        if(f=1)
        {
          cout<<"Enter the first operand and Second operand: "<<endl;
          cin>>a>>b;
          d=a-b;
          cout<<"Subtraction between two numbers is: "<<d<<endl;
        }
        break;
    case 3:
        cout<<"\t\t*****Multiplication********"<<endl;
        cout<<"Enter the first operand and Second operand: "<<endl;
        cin>>a>>b;
        if(a<10 && b<99 || b<10 && a<99)
         {
        d=a*b;
        cout<<"Multiplication between two numbers is: "<<d<<endl;
        }
        break;
    case 4:
        cout<<"\t\t*****Module Application********"<<endl;
        cout<<"Enter the first operand and Second operand: "<<endl;
        cin>>a>>b;
        d=a%b;
        if(d>10 || d>99)
        {
         cout<<"Module between two numbers is: "<<d<<endl;
        }
        cout<<"Would you like to continue 1 for YES or 2 For Back Main menu"<<endl;
        cin>>f;
        if(f=1)
        {
          cout<<"Enter the first operand and Second operand: "<<endl;
          cin>>a>>b;
          d=a-b;
          cout<<"Module Application between two numbers is: "<<d<<endl;
        }
        break;
    case 5:
        cout<<"\t\tRandom Arithmetic"<<endl;
        char Math_op; int expected;
        cout<<"Enter the first operand and Second operand: "<<endl;
        cin>>a>>b;
        switch(rand() % 4)
        {
        case 0:  Math_op = '+'; expected = a + b; cout<<expected<<endl; break;
        case 1:  Math_op = '-'; expected = a - b; cout<<expected<<endl; break;
        case 2: Math_op = '*'; expected = a * b; cout<<expected<<endl; break;
        case 3: Math_op = '%'; expected = a % b; cout<<expected<<endl; break;
        }
        break;
    case 6:
     exit(0);
        break;
    }
    }




}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS