Chapter 6 Quiz Starting Out With C++ 003

Which of the following are parts of the function definition?

a. return type
b. name
c. parameter list
d. argument list
e. body

Chapter 6 Quiz Starting Out With C++ 002

It is a good idea to break up problems into smaller problems that are easily solved?

a. true
b. false

Chapter 6 Quiz Starting Out With C++ 001

A program may be broken up into manageable _____

a. sections
b. blocks
c. subroutines
d. functions

CH5: Programming Challenge: #26

26. Using Files--Savings Account Balance Modification
Modify the Savings Account Balance program described in Programming Challenge 16 so that it writes the final report to a file.

Solution:

CH5: Programming Challenge: #17

17. Sales Bar Chart
Write a program that asks the user to enter today s sales for ve stores. The program should then display a bar graph comparing each store s sales. Create each bar in the bar graph by displaying a row of asterisks. Each asterisk should represent $100 of sales.

Here is an example of the program's output.

Enter today's sales for store 1: 1000 [Enter]
Enter today's sales for store 2: 1200 [Enter]
Enter today's sales for store 3: 1800 [Enter]
Enter today's sales for store 4: 800 [Enter]
Enter today's sales for store 5: 1900 [Enter]
SALES BAR CHART
(Each * = $100)

Store 1: **********
Store 2: ************
Store 3: ******************
Store 4: ********
Store 5: *******************

Solution:

CH5: Programming Challenge: #15

15. Payroll Report
Write a program that displays a weekly payroll report. A loop in the program should ask the user for the employee number, gross pay, state tax, federal tax, and FICA withholdings. The loop will terminate when 0 is entered for the employee number. After the data is entered, the program should display totals for gross pay, state tax, federal tax, FICA withholdings, and net pay. 

Input Validation: Do not accept negative numbers for any of the items entered. Do not accept values for state, federal, or FICA withholdings that are greater than the gross pay. If the sum state tax + federal tax + FICA withholdings for any employee is greater than gross pay, print an error message and ask the user to re-enter the data for that employee.

Solution: