Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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_2

Step: 3

blur-text-image_3

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

Moving Objects Databases

Authors: Ralf Hartmut Güting, Markus Schneider

1st Edition

0120887991, 978-0120887996

More Books

Students also viewed these Databases questions

Question

Provide examples of Dimensional Tables.

Answered: 1 week ago