Problem

In this exercise, you explore the use of integers in monetary calculations. a. Follow...

In this exercise, you explore the use of integers in monetary calculations.

a. Follow the instructions for starting C++ and opening the Advanced15.cpp file. If necessary, delete the two forward slashes that appear before the system("pause"); statement, and then save the program. Run the program. When you are prompted to enter the gross pay, type 45.13 and press Enter. The net pay that appears on the computer screen is incorrect because it is not the result of subtracting the taxes from the gross pay. Press any key to stop the program.

b. Reviewthe code contained in the Advanced15.cpp file.The #include directive tells the C++ compiler to include the contents of the iomanip file in the current program. The iomanip file contains the definition of the setprecision stream manipulator, which appears in the cout << fixed << setprecision(2) << endl; statement. The fixed stream manipulator is defined in the iostream file, and it forces a real number to display a specific number of decimal places, as specified by the setprecision stream manipulator. In this program, the output values will display with two decimal places. You will learn about the directive and both stream manipulators in Chapter 5.

c. Why does the net pay appear as $33.85 rather than $33.84? Hint: Change the cout << fixed << setprecision(2) << endl; statement to a comment, and then save and run the program. Type 45.13 as the gross pay and press Enter. Study the output, and then stop the program and change the comment back to a statement.

d. Use the comments that appear in the Advanced15.cpp file to modify the program’s code. (Start with the comment on Line 14 in the program.) Why do you need to add .5 to the expressions that calculate the federal and state taxes? e. Save, run, and test the program to verify that it is working correctly, and then stop the program.

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 4