IUP Computer Science
CO 110 Spring 2000

Project #4
(due by 5 pm 27 March 2000)

The file BIRDS.DAT contains a summary of the observations made by the cartoon chapter of the Audubon Society during the annual Christmas bird count. Each line of the file contains the information about one "person's" observations, with a layout as follows:

name:  SW count   SE count   PR count   SO count   O count
where the name is in the form "last name, first name" and is followed by a colon and the five counts represent the number of swimming birds (SW), sea birds (SE), birds of prey (PR), song birds (SO), and other birds (O) which the person observed. Here are the first four lines of the file as a sample.

Mitchell, Dennis:	 26  103    6   13   37
Brown, Charlie:		144   98   17    7   22
Oop, Alley:		 38    0   97  201  118
Bailey, Beetle:		 54   11   84  178   66

You are to write a C++ program which includes (at least) two functions to process this file. First, you are to use a function named GetMost to determine which type of bird a person saw the most of and how many that was. Your main function should use the information provided by GetMost to write a report showing each person's name, which type of bird they saw the most, and how many birds of that type s/he saw. The report must be written to another file, named ANSWERS.TXT. For example, the first four lines of the report in the output file might look like this:

Mitchell, Dennis saw more sea birds (103)
Brown, Charlie saw more swimming birds (144)
Oop, Alley saw more song birds (201)
Bailey, Beetle saw more song birds (178)

After you have written the information about each participant in the bird count, you are to use a second function named GetCounts to get the total number of birds seen by all participants in each of the five categories. That is, GetCounts should determine the total number of swimming birds, sea birds, birds of prey, etc. and write these totals with a label identifying which is which to the ANSWERS.TXT file. Below is a sample of the output your program might generate for these totals.

Swimmers   Sea Birds   Birds of Prey   Song Birds   Others
    2139        1840            1183         2370     2117

One of the simplest ways to write the two functions as described is to use the technique shown in Exercise #5 in which a file was read twice. If you try to do everything in one reading of the file by combining the reporting of what type of bird was seen most by each person with the tallying of the total numbers of each bird, you will have a very hard time writing the two functions in such a way that they each do exactly what is described above.

To get a copy of the BIRDS.DAT file, go to any lab on campus and look on the I: disk drive. You will find BIRDS.DAT in the jlwolfe folder on the I: drive. That is, the path to the file is I:\jlwolfe\birds.dat

Hand in a printout of your program and a printout of the ANSWERS.TXT file. You should be able to print ANSWERS.TXT by bringing it into NotePad and printing. Also hand in a 3 1/2 inch floppy disk with your source program (the .cpp file) and ANSWERS.TXT on it; none of the other files are needed.