Question: Write a program, compute.cpp , that repeatedly commands of a , m or q until a q is entered. For the a (add) and m

Write a program, compute.cpp, that repeatedly commands of a, m or q until a q is entered. For the a (add) and m (multiply) commands, the program will read an integer and a number of times to add/multiply the integer.

The program should compute a running sum/product of the integer added/multiplied that number of times. Of course, you could just compute the answers directly, but you are required to write a for loop to perform a running computation. The program should print the result in equation form (will need to loop to print this also). Use the x character to represent multiplication in the output.

The program should print an error message when an illegal menu character is entered and a final message when the program is done. You may assume that the times value entered will be greater than one (observe what happens when it isnt!).

Here is a sample run (user input in bold):

Enter a (add), m (multiply) or q (quit): a

Enter the number to add: 17

Enter the number of times to add: 5

17 + 17 + 17 + 17 + 17 = 85

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!