CPSC 170 Spring 2003
Program 1: Client Sales

Problem Description

Company XYZ has ambitious salespeople who are interested in organizing their sales and keeping statistics about which clients they are selling the most to. Each salesperson keeps his or her sales information in files, one file for each month. Each line in a sales file contains the information for a single sale -- the client's name and the dollar amount of the sale. A salesperson might sell to a single client many times in the same month, in which case there will be many lines for that client in the same file. Of course, the same client may also appear in different files.

The salespeople have requested a program to read the sales information from one or more files and consolidate the sales for each client. So if salesperson Joe had three sales to client ABC, for amounts $50, $200, and $175, he really just wants to know that he sold a total of $425 to ABC. The salespeople would also like the following information:

Your job is to write a program to carry out these tasks as outlined below.

Program Structure

You will need to write two classes for this program, in addition to the driver. Class ClientSales should hold three pieces of information -- the name of a client, the number of sales to that client, and the total amount of sales to that client. It should have the following public methods:

Class SalesInfo should hold all of the sales information for a single salesperson. It should use an array of ClientSales objects to store this information. SalesInfo should have the following public methods:

You will need some private methods as well, including the following: You may wish to use other private methods as well.

Your driver should take the files to be processed on the command line. It should create a SalesInfo object and repeatedly call the processFile method for that object to process the given files. It will then use the toString and maxNumSales methods to print the remaining information. Note that the driver does not need to manipulate any ClientSales objects directly.

Input

Your program should take the files to be processed on the command line, e.g.,
java TestSales salesFile1 salesFile1
There can be an arbitrary number (> 0) of input files If no such files are provided, the program should print a "usage" message and terminate.

Each input file will be in the following format:

client 
saleAmt
client 
saleAmt
client 
saleAmt
...
end
You may assume that there are no spaces in the client names. The last line will always be "end" (no quotes). It is possible that a salesperson will not have any sales for the given month, in which case the file will contain only "end". No salesperson will sell to more than 25 different clients, but there may be more than 25 individual sales, that is, more than 25 lines in any given input file or combination of files.

Output

Your output should contain all of the required information and be neatly formatted. For example, consider the input files below:
Input File 1                Input File 2
---------------             -------------
SuperSteel                  ABCParts 
12.15                       10
ABCParts                    TiresLtd 
123.50                      100.75
SuperSteel                  end
50
SuperSteel 
35.67
end
Output for these files might be as follows:
Client       $ Sales     # of Sales
-----------------------------------------
ABCParts     $133.50          2
TiresLtd     $100.75          1 
SuperSteel   $97.82           3

Total sales: $332.07

Highest # of sales:   SuperSteel     $97.82        3

What to Turn In

Turn in hardcopy of all of your classes. Tar your prog1 directory and e-mail it to me with cpsc170 prog1 in the Subject line.