Can anyone help on following program using c language Please

Can anyone help on following program? using c++ language. Please seprate header file, implementation file, and main file.

Redo the following program so that your program handles exceptions such as division by zero and invalid input.

Write a program that mimics a calculator. The program should take as input two integers and the operation to be performed. It should then output the numbers, the operator, and the result. (For division, if the denominator is zero, output an appropriate message). Some sample outputs follow:
3 + 4 = 7
13 * 5 = 65

Thank You.

Solution

C++ Code:

#include <iostream>
using namespace std;

int main()
{
int a, b;
char op,ch;
cout << \"Enter Two Numbers with Operand(opr1 opt opr2)\" << endl;
cin >> a >> op >> b;
while(1){
   switch(op){
       case \'+\':cout << \"Performing Addition Operation\" << endl<< \"\ \\t\" << a << \" + \" << b << \" = \" << a+b << endl;
           break;
       case \'-\':cout << \"Performing Subtraction Operation\" << endl<< \"\ \\t\" << a << \" - \" << b << \" = \" << a-b << endl;
           break;
       case \'*\':cout << \"Performing Multiplication Operation\" << endl<< \"\ \\t\" << a << \" * \" << b << \" = \" << a*b << endl;
           break;
       case \'/\':   if(b==0){
                       cout <<\"Division Operation is failed due divided by zero i.e b=0\"<<endl;
                   }
                  else
                      cout << \" Performing Division Operation\" << endl<< \"\ \\t\" << a << \" / \" << b << \" = \" << a/b << endl;
                   break;
   }
   cout<<\"Do you want to continue:(N/Y)\"<<endl;
   cin>>ch;
   if(ch==\'Y\'|| ch==\'y\'){
       cout << \"Enter Two Numbers with Operand(opr1 opt opr2)\" << endl;
           cin >> a >> op >> b;
   }else{
       break;
   }
  
}
return 0;
}

Output:

Enter Two Numbers with Operand(opr1 opt opr2)

3 * 4

Operation is to be performed is Multiplication

   3 * 4 = 12
Do you want to continue:(N/Y)

Y
Enter Two Numbers with Operand(opr1 opt opr2)

5 - 2
Operation is to be performed is Subtraction

   5 - 2 = 3
Do you want to continue:(N/Y)

Y
Enter Two Numbers with Operand(opr1 opt opr2)

6 / 0
Operation is to be performed is Division is failed due divided by zero i.e b=0
Do you want to continue:(N/Y)

Y
Enter Two Numbers with Operand(opr1 opt opr2)

12 / 4
Operation is to be performed is Division

   12 / 4 = 3
Do you want to continue:(N/Y)

N

Can anyone help on following program? using c++ language. Please seprate header file, implementation file, and main file. Redo the following program so that you
Can anyone help on following program? using c++ language. Please seprate header file, implementation file, and main file. Redo the following program so that you

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site