IUP Computer Science
CO 110 Fall '99
Project #6
(Due 10 December 1999)
Write a C++ program to keep track of the standings for a diving competition. The scores for the competition are in a file. On the first line of this file is a single number that represents the number of competitors. Following this, for each competitor, there are four lines of information: the divers name (20 characters) on one line, the first dive results on the next line (degree of difficulty and the nine judge's scores), the second dive results on the next line, and the third dive results on the next line. These four lines look like this in the file.
Diver's name
difficulty-of-first list-of-judges-scores
difficulty-of-second list-of-judges-scores
difficulty-of-third list-of-judges-scores
The file SAMPLE.TXT on the I: disk, in the JLWOLFE folder contains a small sample of what a dive competition file looks like. You can get a copy of this file from I:\JLWOLFE\SAMPLE.TXT It contains:
3
Patterson, Michael
2.8 7.5 7.0 8.0 7.5 7.5 8.5 8.0 7.5 8.5
3.0 7.0 6.5 7.0 7.5 7.5 8.0 6.5 7.0 7.5
2.7 8.5 8.5 8.5 8.0 8.0 7.5 8.0 7.5 8.0
Van Pelt, Linus
3.1 7.0 7.0 6.5 6.0 7.0 7.5 7.0 7.0 7.5
2.6 8.0 8.5 9.0 9.0 8.5 8.0 9.0 8.5 8.5
2.9 8.0 8.5 9.0 9.0 8.5 9.5 9.0 8.0 9.0
Kent, Clark
2.8 8.5 8.5 8.0 9.0 9.5 9.5 9.0 8.0 8.5
3.0 7.5 7.5 7.5 7.0 8.0 8.0 7.5 7.0 8.0
2.7 6.5 6.0 6.0 6.5 6.0 5.5 6.0 6.5 5.5
Your program must calculate each diver's dive score for each of the three dives, determine the total score (sum of the three dive scores), and then output the competition standings - showing the name, dive score for each dive, and total score for each diver in ranked order from highest total to lowest total. The output should look something like this for the data in SAMPLE.TXT Use single spacing for the lines of the table.
Name Dive Scores Total
Dive 1 Dive 2 Dive 3
Van Pelt, Linus 151.90 156.00 176.90 484.80
Patterson, Michael 152.60 150.00 152.55 455.15
Kent, Clark 170.80 159.00 114.75 444.55
To compute a dive score, do the following: Eliminate the highest and lowest scores from the nine judges' scores for a dive. Sum the remaining seven scores and multiply this sum by the degree of difficulty. This product is the dive score for that dive. Judges' scores for a dive are in the range of 0 to 10 in steps of 0.5. Degrees of difficulty range from 2.0 to 3.3.
SPECIFIC PROGRAM REQUIREMENTS:
For this program, you are required to used certain programming features that were introduced during this course; they are:
1. Your program must prompt for and read in the name of the file containing the dive information. The program must be able to use any file specified from the same folder as the source program. In the program, do NOT specify a disk and/or folder where the folder must be located. SAMPLE.TXT is only a sample, I will run your program on a much larger file of dive information.
2. You should create more complex data than is contained in SAMPLE.TXT to test your program before handing it in. I will not give you a copy of the data I will use; however, my data will meet the same form specifications given above.
3. Your program must use at least one two-dimensional array.
4. Your program must use at least three functions (including main); and you must document these functions as in the book (and style guide).
5. Your program must store each diver's name in a string which can be output as a string, not output with a loop.
6. Your program should define at least one datatype (using typedef) to help with the names.
7. Your program must output the results in a table form with appropriate headings so that values line up; thus, you must use the manipulator functions to format the results.
8. Your program must have a statement such as cin >> junk;
where junk is of type char, just before the return 0; statement in main. This will make execution without recompiling possible; and I will still be able to see the results.
Hand in a floppy disk which contains the source program (.cpp file) and the executable (.exe) file. Also, hand in a printout of the program.