Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help making a calculator in C++ following the parameters below. I am absolutely stuck.. Thank you! Objectives Using an ifor switch statement Using

I need help making a calculator in C++ following the parameters below. I am absolutely stuck.. Thank you!

image text in transcribedimage text in transcribed

Objectives Using an ifor switch statement Using a while loop Instructions: Code a simple calculator. It need not be anything overly fancy, but it is up to you to take it as far as you want. You will be creating this program in three small sections. You have the menu the performance of the basic arithmetic operations (Addition, Subtraction, Multiplication, and Division), and the looping. You may want to get the switch menu working first, and then fill in the code for these four arithmetic operations The program will keep a running total. It should print the subtotal out after each and every calculation. In addition, the total should be printed before the program quits. So with that being said, the program needs to define a data field, named total at the beginning of main and set it to zero Part A: Designing the menu system Menu systems in C+ (and other languages) are often represented as a switch statement. Design a switch statement that handles five cases and a default case case 0 Exit case 1- Addition case 2-Subtraction case 3-Multiplication case 4 Division default Error message Make sure to print out a list of options explaining to the user what each case does, like "Enter 1 to add a number to total" or "Enter 2 to subtract a number from total". This menu should appear before the switch statements. It is also vital to allow the user to input their choice of 0-4 Part B: Filling in the Cases At this point, you should have a working menu that does nothing. It is time to add code to each of the cases so that they will do the function you displayed to the user. Start by writing code inside of case 1 that will prompt the user to enter a single number. Since this case is for addition, you will want to make sure to add the number you entered to the running total. Once this works, you should do the same for the other mathematical functions. Only substituting in the other three operation (Subtraction, Multiplication, and Division) Part C: Repetition Allowing the user to select which function then input data is nice. But how often do you open the calculator and do just a single calculation? It would be a good idea to wrap your entire menu into some sort of structure that allows it to repeat more than a single time. If you were to use such a thing, how would you stop it? Part C is to surround your entire program thus far with a loop that allows it to be run more than once. It would also be a good idea to allow for exiting this loop. Be sure to print out a sub total each time the loop runs Run: You will do two runs of this program. Run One: Add 10, multiply by 5.5. divide bv 3. add 20.5, subtract 5 and exit. The final total should be 33.83

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

Essentials of Database Management

Authors: Jeffrey A. Hoffer, Heikki Topi, Ramesh Venkataraman

1st edition

133405680, 9780133547702 , 978-0133405682

More Books

Students also viewed these Databases questions

Question

What is Selenium? What are the advantages of Selenium?

Answered: 1 week ago

Question

Explain the various collection policies in receivables management.

Answered: 1 week ago

Question

What are the main objectives of Inventory ?

Answered: 1 week ago