Chapter 6 Quiz Starting Out With C++ 006

Which of the following is the function header?

a. calculateBonus()
b. decimal calculateBonus()
c. return calculatedBonus;

Chapter 6 Quiz Starting Out With C++ 005

What function is automatically called when a program starts in C++?

a. the include function
b. the main function
c. the return function
d. the displayMessage function

Chapter 6 Quiz Starting Out With C++ 004

What is a void function?

a. a function that does not have a body
b. a function that does not return a value
c. a function that doesn't have any parameters
d. a function that doesn't have any arguments

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:

CH5: Programming Challenge: #10

10. Average Rainfall
Write a program that uses nested loops to collect data and calculate the average rainfall over a period of years. The program should rst ask for the number of years. The outer loop will iterate once for each year. The inner loop will iterate twelve times, once for each month. Each iteration of the inner loop will ask the user for the inches of rainfall for that month. After all iterations, the program should display the number of months, the total inches of rainfall, and the average rainfall per month for the entire period.

Input Validation: Do not accept a number less than 1 for the number of years. Do not
accept negative numbers for the monthly rainfall.

Solution:


CH5: Programming Challenge: #2

2. Characters for the ASCII Codes
Write a program that uses a loop to display the characters for the ASCII codes 0 through 127. Display 16 characters on each line.

Solution