< previous page page_705 next page >

Page 705
Programming Problems
1. A company wants to know the percentages of total sales and total expenses attributable to each salesperson. Each has a data line giving his or her last name (maximum of 20 characters), followed by a comma, followed by his or her first name (maximum of 10 characters). The next line contains his or her total sales (int) and expenses (float). Write a program that produces a report with a header line containing the total sales and total expenses. Following this header should be a table with each salesperson's first name, last name, percentage of total sales, and percentage of total expenses.
2. Only authorized shareholders are allowed to attend a stockholders' meeting. Write a program to read a person's name from the keyboard, check it against a list of shareholders, and print a message saying whether or not the person may attend the meeting. The list of shareholders is in a file inFile in the following format: first name (maximum 10 characters), blank, last name (maximum 20 characters). Use the end-of-file condition to stop reading the file. The maximum number of shareholders is 1000.
The user should be prompted to enter his or her name in the same format as is used for the data in the file. If the name does not appear on the list, the program should repeat the instructions on how to enter the name and then tell the user to try again. A message saying that the person may not enter should be printed only after he or she has been given a second chance to enter the name. The prompt to the user should include the message that a Q should be entered to end the program.
3. Enhance the program in Problem 2 as follows:
a. Print a report showing how many stockholders there were at the time of the meeting, how many were present at the meeting, and how many people who tried to enter were denied permission to attend.
b. Follow this summary report with a list of the names of the stockholders, with either Present or Absent or Absent after each name.
4. A life insurance company has hired you to write a program to print a list of their customers and the premium that each customer pays. Premiums are based on the age the customer was when he or she became a customer. The following table is used to determine each customer's premium, but these rates are subject to change.
Age
Premium
25
$277.00
35
287.00
45
307.00
55
327.00
65
357.00

Each age listed in this table is the upper limit for the premium. For example, if a customer signed up for a policy when she was 37, she would pay $307.00.
Write a program that reads the table into parallel arrays, then reads in the customers' names and ages when they bought the policies into another pair of parallel arrays. The table and the customers' names and ages are stored in two files. Print out a formatted, labeled list showing each customer's name, his or her age when the policy was bought, and the customer's premium.

 
< previous page page_705 next page >