Question
a C++ program that mimics a calculator. The program should take as input two integers and the operation to be performed. Sample user inputs: 3
a C++ program that mimics a calculator.
The program should take as input two integers and the operation to be performed.
Sample user inputs:
3 + 4
10 - 5
2 * 4
4 / 2
It should then output the numbers, the operator, and the result. (For division, if the denominator is zero, output an appropriate message: "Cannot divide by zero")
Sample outputs:
3 + 4 = 7
10 - 5 = 5
2 * 4 = 8
4 / 2 = 2
***Use switch statement for operators (+, -, *, /). If the user types a different operator, prompt the user: "Illegal Operation", and terminate the program.)
OUTPUT:
**********************************************************************
Enter two integer numbers with an arithmetic operator (ex. 3 + 4): 3 + 4
3 + 4 = 7
**********************************************************************
Enter two integer numbers with an arithmetic operator (ex. 3 + 4): 10 - 5
10 - 5 = 5
**********************************************************************
Enter two integer numbers with an arithmetic operator (ex. 3 + 4): 2 * 4
2 * 4 = 8
**********************************************************************
Enter two integer numbers with an arithmetic operator (ex. 3 + 4): 4 / 2
4 / 2 = 2
**********************************************************************
Enter two integer numbers with an arithmetic operator (ex. 3 + 4): 3 % 2
Illegal Operation.
**********************************************************************
Enter two integer numbers with an arithmetic operator (ex. 3 + 4): 3 / 0
Can't divide by 0.
*********************************************************************
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started