Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

SQL Server Query Performance Tuning

Authors: Sajal Dam, Grant Fritchey

4th Edition

1430267429, 9781430267423

More Books

Students also viewed these Databases questions

Question

=+j Explain the essential nature of repatriation.

Answered: 1 week ago