Date: Mon, 11 Nov 1996 17:13:06 GMT Server: NCSA/1.5 Content-type: text/html Last-modified: Tue, 15 Oct 1996 00:23:42 GMT Content-length: 8738
(Notes for people unfamiliar with golf: the object of golf is to obtain as low a score as possible. Your score for each hole is the total number of shots it takes to get the golf ball in the hole. Your score for the entire round is the sum of your scores for each holes. "Par" for a hole is generally the score that a good golfer would receive on that hole, and par for the entire course is the sum of the pars for each individual hole. Golfers try to get a score lower than par for the course. For example, each hole in a 9 hole course would have a par score. If par for each hole was 4, then par for the entire course would be 36. If a golfer scored 3 on each hole on that course, the golfer would have a score of 27, which is very good, since it is less than, or "under" par. In fact, since 27 - 36 = -9, we say the golfer is 9 under par. If, on the other hand, a golfer scored 5 on each hole, the golfer would have a score of 45, and would be 9 over par, which is not as good. Note that 45 - 36 = 9.)
You have been assigned to work at a golf tournament being held at Big Shank. A number of players are each playing one round on each course. Thus, each player will have a different score for each of the 5 courses. In addition, each of the five 9-hole courses at Big Shank has a different par score. All of this data will be stored into an input file. The file will have the following form:
36 35 36 33 32 124 37 33 35 37 35 2353 37 35 34 32 33 3457 40 31 32 35 28 532 32 35 34 34 30 -1The first line lists the par score for each of the 5 courses. Thus, par for the first course is 36, par for the second is 35, and so on.
The next 4 lines list the scores for each individual golfer on each course. The first part of each of these lines is the "golfer id" number, which you may assume fits into an int. You may also assume that each ID number is unique. The remaining 5 numbers hold that golfer's score for each of the 5 courses. Thus, the first golfer has an ID of 4343, and has scores of 37, 33, 35, 37, and 35.
Finally, a -1 is included in the file, which means that the listing of scores is now complete. When you read in a -1 instead of a positive ID, you can assume all the players have been listed. (If there is any input data after the -1, you can ignore it).
NOTE: The data in the actual input files will be different than the data given above. Thus, you may NOT assume anything about the number of golfers, the par scores for the 5 rounds, and so on.
Also, the input file may have a different spacing and line breaks than the one listed above. For example, the above data could be present in the input file in the following form:
36 35 36 33 32 124 37 33 35 37 35 2353 37 35 34 32 33 3457 40 31 32 35 28 532 32 35 34 34 30 -1Note that the data is the same, the only difference is that the spacing and line breaks have changed.
Your job is to:
Player ID Round 1 Round 2 Round 3 Round 4 Round 5 Final Par Par 36 35 36 33 32 - 124 37 33 35 37 35 5 2353 37 35 34 32 33 -1 3457 40 31 32 35 28 -6 532 32 35 34 34 30 -7 Average 36.50 33.50 33.75 34.50 31.50 -2.25 The winner is player #532 with a score of 7 under par.
The following 4 lines list data for each individual golfer. First, the golfer's ID is displayed. Next, the golfer's scores on each of the courses is displayed. Finally, the golfer's overall "par" score is displayed, in the Final Par column.
For example, the golfer with the ID 124 scored 37, 33, 35, 37, and 35, on rounds 1-5 respectively. Thus, these scores are listed in the 5 "Round" columns. The sum of these scores (177) is 5 more than the sum of the par scores for the 5 courses (172). Thus, a 5 is displayed for golfer 124 in the final par column, where 5 means "5 over par."
The next golfer, with an ID of 2353, scored 37, 35, 34, 32, and 33 in the 5 rounds. Thus, that golfer's total score (171), is one less than the par score, so a -1 is recorded as the golfer's final par, signaling 1 under par.
The scores for the remaining 2 golfers are then printed out, as well as their final scores (6 and 7 under par).
The line beginning with Average lists the average total score for each of the 5 courses. For example, since the average of 37, 37, 40, and 32 is 36.5, 36.50 is printed as the average for Round 1. The remaining averages for the other 4 rounds are printed out. Finally, the average tournament par score for all golfers is printed out.
The final line displays the ID of the golfer who won as well as that golfer's score relative to par.
Note that to receive full credit on this assignment, you must format your output file in exactly the same way as the sample above. For example, each column should be 10 characters wide, and the averages should be displayed with 2 trailing decimal points.
We have provided a test input file for you to use, which is called "golfin.txt". You may find it in the r:\public\program4 directory. Please note that I may use a different input file when testing your program, but it will have the same name and will be formatted in the same way as golfin.txt and the example given above. You should also be sure to make up your own input files to use to test your program as well.
You should name the output file produced by your program "golfout.txt."
Your solution should use functions where appropriate, but you may not use global variables. You should check to make sure the file was opened correctly. You need not do any error checking when you read in the data from the file except for the following: if one of the input scores is smaller than the number of holes (9), which is of course impossible, your program should penalize that cheater by changing the score on that round to 200.
Your program should print out the following statements to the screen:
Beginning file processing.... Done with file processing. Output file written.