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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started