Question: Its' C ++ Please create a Math Calculator Program as follows: 1. Display a Menu of Arithmetic Functions to the user, allowing them to choose

Its' C ++

Please create a Math Calculator Program as follows:

1. Display a Menu of Arithmetic Functions to the user, allowing them to choose Summation, Factorial, Exponential, or Exit the Program.

2. Prompt for and input the user choice of Arithmetic Function.

3. Execute the code to input user's positive number, then perform the selected math function. Display those results.

4. Redisplay the main menu. Continue in this fashion until the user enters option 4. Then gracefully stop the program.

Validate menu option input and math function integer input appropriately.

1. Use a do-while loop to drive the menu. See Program 5-8 in your textbook for driving the menu.

2. Use a switch statement to decide which function to execute and to validate menu input.

3. Use a for loop for the arithmetic calculations.

4. Use a while loop to validate user input inside of each math function.

See the pseudocode below for help on how to construct all of this.

-----------

do loop

output menu

input menuChoice

Switch (menuChoice)

Case (1) // Code for summation

total = 0

input maxNum

while maxNum < 1 //validate the input using a while loop

output error message

input maxNum

end while // end of input validation

for (counter = 1; counter <=maxNum; counter++) //do the calculations with a for loop

total = total + counter

end for loop

ouptut total, maxNum...

Case (2)

//code for factorial which is just like summation except initialize total to 1 (instead of 0), and use * instead of + in the loop. Easy peasy. Validate for negative input.

Case(3):

//input the exponent. assume the base is 2. then do the math for 2**exponent. Make sure your variables are large enough to hold the answer. Validate for negative input.

Case(4): output goodbye line

Default: output that number is not on the menu //that's the validation part.

End Switch

while (menuChoice !! 4) loop // it's the bottom of the do loop from up above

end the program.

Extra notes:

**Remember to reset the variables you use to hold the summation , product, or exponential each time through the menu loop. That trips students up every time.

**Make your output look good - clean and professional.

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!