As a not-for-profit institution, The Chicago Moliere Theater depends on financial support from its donors. To this end, its staff needs to maintain and present useful information on who are the theater's principal donors. For this assignment, you will create a simple program that reads in data on donations and presents lists of donors sorted by the number of donations and the total amount of the donations.
The file names.dat is a list of donor names and their donor
ID. The format of this file has the name on one line and the ID on
the next line. Here is a short example:
Jones, Sam
2
Smith, Alfred
3
Miller, Andrew
5
Because some donors want to remain anonymous, not all names are listed in this file.
1 20.00
2 30.00
1 20.00
3 50.00
2 20.00
6 70.00
2 30.00
Your program should read in these two files and then present two sorted lists. The first list should provide the donor name, the number of donations made by that donor and the total amount of donations made by that donor. It should have up to 10 entries and be sorted starting with the donor with the greatest number of donations. The second list should provide the same information, having up to 10 entries, but be sorted starting with the donor with the greatest total amount of donations. The lists should be written to standard output. If the name is not in the names file, you should list the donor as "Anonymous".
Assuming your program were to read in the two example files, it might produce the following output:
*** Donors sorted by the number of contributions ***
Name Number Total (dollars)
Jones, Sam 3 80.00
Anonymous 2 40.00
Anonymous 1 70.00
Smith, Alfred 1 50.00
*** Donors sorted by contribution totals ***
Name Number Total (dollars)
Jones, Sam 3 80.00
Anonymous 1 70.00
Smith, Alfred 1 50.00
Anonymous 2 40.00
Your assignment is greatly simplified by the Donations class, which you must use to store and sort the information from the donations file. You can download the class files (you will need to unzip them) and view its specification. While we will go over its source code in class, you do not need it for this assignment.
Your program should be written in the file DonorReport.java and should run by executing its main method. You are not required to write any additional classes for this assignment and may choose to only use static methods and variables when writing your program.
Before the due date and time, you should submit the following file through the submission Web page:
If for some reason you are unable to submit the file, you may email me your program as an attachment.