Project #4
(Donation Competition)
(Due 23 March 2007)
Each year, the US Postal Service sets aside a day on which the letter carriers collect non-perishable food from the households on their routes and give the food to the local charitable organizations for distribution to the needy. In Johnstown, the letter carriers have a friendly competition among themselves to see which of them can be most successful in collecting the food items. There are three prizes that are given based on what the letter carriers collect: the Top Gleaner Award goes to the letter carrier who collects the most total items; the Aching Back Award goes to the letter carrier whose collection weighs the most; and the Cooperation Award goes to the letter carrier that collects food from the highest percentage of households.
For this year's donation day, the counts have been made and the food items have been weighed. The information about each of the letter carriers is now held in a file named donations.txt which can be found on the I: drive in I:\jlwolfe\110\donations.txt The form for each line of the file is as follows:
LastName, FirstName No-of-Households No-of-Donors No-Items Weight . . .
where the carrier's last name and first name are guaranteed to be one word each and there is a (No-Items , Weight) pair for each donor on the carrier's route; i.e., this pair occurs No-of-Donor times. Here is part of the first few lines of the donations.txt file (there are too many items and weights to show them all):
Alligator, Albert 116
8 7 3.7 4 4.2 3 1.4 1 0.5 6 3.4 7 4.3 4 4.3 7 7.7
Arbuckle, Jon
126 36 5 1.5 2 1.2 3 1.8 1 1.1 5 3.7 7 7.8 2 2.3 . . .
Bailey, Beetle
172 13 6 2.0 8 8.5 1 0.5 1 0.5 5 2.2 2 0.5 5 2.1 . . .
Brown, Buster
96 35 2 1.9 4 4.3 2 1.5 4 1.7 5 4.6 7 2.1 2 0.6 . . .
Albert Alligator's route had 8 donors (out of 116 households on the route); the first donor gave 7 items weighing 3.7 pounds, the second gave 4 items weighing 4.2 pounds, the third 3 items weighing 1.4 pounds, etc.
You are to write a program that reads the donations.txt file and displays the following information. For any floating point value, one digit to the right of the decimal point should be displayed.
Carrier Name
Items Weight Percent
Alligator, Albert
39 29.5 6.9
Arbuckle, Jon
161 99.3 28.6
Bailey, Beetle
55 42.9 7.6
Brown, Buster
146 108.8 36.5