Question: C++ For this lab, we will build a 4-function calculator, performing calculations only on integers . The user should be prompted to continually enter an

C++

For this lab, we will build a 4-function calculator, performing calculations only on integers. The user should be prompted to continually enter an equation in the form of a + b or a x b, etc. The calculator should support the following functions:

Addition (a + b)

Subtraction (a - b)

Multiplication (a x b)

Division (a / b)

Each time a validcalculation has been entered, the results of the operation should be printed out also in the form of an equation (e.g., 3 x 7 = 21). I will show you how to read 3 parameters from the same input line. Also, you need to use a switch statement to help you code this lab assignment. Some kind of repetitive loop will also be needed.

Divide-by-zero any number divided by 0 is invalid

An example execution of the calculator program is given below.

Example execution:

$ ./calculator.out

Enter an equation or 0 x 0 to exit: 12 / 4

12 / 4 = 3

Enter an equation or 0 x 0 to exit: 4 x 2

4 x 2 = 8

Enter an equation or 0 x 0 to exit: 5 x -10

5 x -10 = -50

Enter an equation or 0 x 0 to exit: 5 + 10

5 + 10 = 15

Enter an equation or 0 x 0 to exit: 10 30

10 30 = -20

Enter an equation or 0 x 0 to exit: 13 / 0

Error -- cannot divide by 0

Enter an equation or 0 x 0 to exit: 0 x 0

Thanks for using the calculator. Goodbye.

$

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!