Programming and Problem Solving with Java

(やまだぃちぅ) #1
577

Programming Problems


1.A company wants to know the percentages of total sales and total expenses
attributable to each salesperson. Each person has a pair of data lines. The first
line contains his or her name, with the last name coming first. The second line
contains his or her sales (int) and expenses (float). Write an application that
produces a report with a header line containing the total sales and total
expenses. Follow this header with a table containing each salesperson’s name,
percentage of total sales, and percentage of total expenses, sorted by the sales-
person’s name. Use one of the list classes developed in this chapter to
implement your solution.
2.Only authorized shareholders are allowed to attend a stockholders’ meeting.
Write an application to read a person’s name from the keyboard, check it
against a list of shareholders, and print a message on the screen saying
whether the person may attend the meeting. The list of shareholders is in a file
called owners, with one name per line, in the following format: first name,
blank, last name. Use the end-of-file condition to stop reading the file. The
maximum number of shareholders is 1,000.
As a stockholder enters the meeting, he or she enters his or her name. If the
name does not appear on the list, the code 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.
3.Enhance the application in Problem 2 as follows:
a.Print a report file showing the number of stockholders at the time of the
meeting, the number present at the meeting, and the number of people who
tried to enter but were denied permission to attend.
b.Follow this summary report with a list of the names of the stockholders,
with either Presentor Absentafter each name.
4.An advertising company wants to send a letter to its clients announcing a new
fee schedule. The clients’ names appear on several different lists in the
company. The various lists are merged to form one file, called clients, but the
company does not want to send a letter twice to anyone.
Write an application that removes any names appearing on the list more
than once. Each data line contains a four-digit code number, followed by a
blank, and then the client’s name. For example, Amalgamated Steel is listed as
0231 Amalgamated Steel
Your code should output each client’s code and name, but no duplicates should
be printed. Use one of the list classes developed in this chapter to implement
your solution.
Free download pdf