Problem

In this exercise, you will create a program that adds, subtracts, multiplies, or divides...

In this exercise, you will create a program that adds, subtracts, multiplies, or divides two integers. The program will need to get a letter (A for addition, S for subtraction, M for multiplication, or D for division) and two integers from the user. If the user enters an invalid letter, the program should not ask the user for the two integers. Instead, it should display an appropriate error message before the program ends. If the letter is A (or a), the program should calculate and display the sum of both integers. If the letter is S (or s), the program should display the difference between both integers. When calculating the difference, always subtract the smaller number fromthe larger one. If the letter isM(or m), the program should display the product of both integers. If the letter is D (or d), the program should divide both integers, always dividing the larger number by the smaller one. Figure 6-51 shows the test data you will use for this exercise.

a. Create an IPO chart for the problem, and then desk-check the algorithm using the test data shown in Figure 6-51.

b. List the input, processing, and output items, as well as the algorithm, in a chart similar to the one shown earlier in Figure 6-47. Then code the algorithm into a program.

c. Desk-check the program using the same data used to desk-check the algorithm.

d. If necessary, create a new project named Intermediate16 Project and save it in the Cpp7\Chap06 folder. Enter your C++ instructions into a source file named Intermediate16.cpp. Also enter appropriate comments and any additional instructions required by the compiler.

e. Save and run the program. Test the program using the same data used to desk-check the program.

REFERENCE: FIGURE 6-47

Step-by-Step Solution

Request Professional Solution

Request Solution!

We need at least 10 more requests to produce the solution.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search
Solutions For Problems in Chapter 6