Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ program. the second picture is kinda startling the program. For this lab, we will build a 4-function calculator, performing calculations only on Integers. The

image text in transcribed

image text in transcribed

C++ program. the second picture is kinda startling the program.

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 +boraxb, etc. The calculator should support the following functions: Addition (a + b) Subtraction (a - b) Multiplication (axb) Division (a / b) Each time a valid calculation 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 O is invalid An example execution of the calculator program is given below. Example execution: $ ./calculator.out Enter an equation or 0x 12 / 4 = 3 to exit: 12 / 4 to exit: 4 x 2 Enter an equation or 0x 4 X 2 = 8 Enter an equation or o xo to exit: 5 x -10 5 x 10 = -50 Enter an equation or o xo to exit: 5 + 10 5 + 10 = 15 Enter an equation or exoto exit: 10 - 30 10 - 30 = -20 Enter an equation or o X o to exit: 13 / Error -- cannot divide by O Enter an equation or 0x to exit: @xe Thanks for using the calculator. Goodbye. 3 #include 4 using namespace std; 6 int main() int num1, num2. answer: char op bool keepgoing: keepgoing - true; while (keepgoing -- true) cout > nul >> op >> num2; switch (op) case '+': answer - num1 nu 2: cout

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

Students also viewed these Databases questions

Question

Explain the nature of human resource management.

Answered: 1 week ago

Question

Write a note on Quality circles.

Answered: 1 week ago

Question

Describe how to measure the quality of work life.

Answered: 1 week ago

Question

Carry out an interview and review its success.

Answered: 1 week ago