*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.
*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
#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;
}
}
}
Comments
Leave a comment