IUP Computer Science
CO 110 Fall '99
Project #4
(Due 29 October 1999)
A file named FISHING.DAT contains the data from the first day of the 23rd Annual Big Bass Day fishing tournament. For each competitor in the tournament, there is a line in the file of the form:
name: id caught weight length weight length ...
which is meant to show the competitor's name (followed by a colon), the 4-digit tournament ID number, the number of fish caught, then a listing of each fish by weight and length. For example, the entry for Barney Google, ID 4522, looks like this:
Google, Barney: 4522 3 1.81 13 1.75 14 1.01 11
indicating that he caught 3 fish, the first weighs 1.81 lbs and is 13 inches long, the second 1.75 lbs and is 14 inches, and the third 1.01 lbs and is 11 inches.
There are two prizes awarded in the tournament: one for the heaviest fish caught and one for the longest fish caught. Results for the first day need to be tallied to show who is in the lead for these two awards. However, to keep the first day's leaders from being followed around the lake, those who are in the lead are to be listed only by ID number, not names.
You are to write a C++ program to read the data in the FISHING.DAT file and produce a report in a file named RESULTS.TXT that identifies (by ID) who is leading in the Heaviest Fish category (and what weight of the heaviest fish so far is) and (by ID) who is leading in the Longest Fish category (and what the length of the longest fish so far is).
Your program is required to use at least two void functions to do its task. One function called Best must be used to find the heaviest fish and longest fish caught by one competitor. The Best function should be invoked once for each competitor. For competitor 4522, Best should find that 1.81 pounds is the heaviest and 14 inches is the longest.
The second required function called Results must write the RESULTS.TXT file. RESULTS.TXT must have a readable form that contains the information mentioned above; the function should write the file as if it were going to display the information on the screen.
There are many other opportunities in this project to make additional functions; and you are encouraged to make more than two; however, the two above are required. Your program should include the usual comments and style conventions.
Hand in a compiler generated printout of your program and a printout of the RESULTS.TXT file - most easily produced with the NotePad program.
----------------
Begin this project by copying the FISHING.DAT file to your floppy disk. This file is currently on the N: disk which should be accessible from any of the public labs on campus. You may refer to the file as N:\FISHING.DAT when copying. Because the N: disk is erased at least once a week, I will try to recopy it to that disk as soon as it is erased. If you try to do the copy and can't find the file, send me e-mail immediately and I will put the file back.
When you write your program on the C: disk, make sure FISHING.DAT is copied into the same directory as your source (.CPP) file. This will make reading the FISHING.DAT file simple; it will be like the examples used in class. Note: the end of file for FISHING.DAT is immediately after the last digit of the size of the last competitor's last fish - there is no newline character on that line.
WARNINGS
1. Do NOT write your program so that it attempts to read FISHING.DAT directly from the N: disk. Attempting to do this will cause interference with students who are trying to copy the file to their disks. Penalties for ignoring this warning are extreme.
2. Do NOT attempt to edit the FISHING.DAT file in any way. Any attempt to open this file with a wordprocessor and then save it (even without making any obvious change) can cause a change in the file that may prevent it from being read properly by your program. You can look at the FISHING.DAT file in a variety of ways - with the DOS TYPE command, with NotePad, or with some wordprocessor; however, you must avoid saving any update of the file.