IUP Computer Science
COSC 110   Spring 2007

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.

  1. A table showing the name of each letter carrier, the total number of food items s/he collected, the total weight of those items, and the percentage of housholds that contributed on the carrier's route.  The values in this table should be displayed in neat columns.  For example, the first few lines of the table should look like this, although the titles on the columns may be different:
  2. 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
     

  3. After the table, display the total number of households that made a contribution in all of Johnstown and the total weight of the food that they gave.
  4. Show the name of the winner of the Top Gleaner Award and the number of items s/he collected.
  5. Show the name of the winner of the Aching Back Award and the weight of the items s/he collected.
  6. Show the name of the winner of the Cooperation Award and the percentage of households that contributed on his/her route.
Hand in a well-documented printout of your program and a printout of the captured output, showing the table and other required output.  Also, copy the program's .cpp file to the handin folder on the P: drive for COSC 110 and the appropriate section.  Be sure to name the .cpp file after yourself so that it can be distinguished from other student file names.  For example, I would name my file wolfep4.cpp