Date: Mon, 11 Nov 1996 17:57:37 GMT
Server: NCSA/1.5
Content-type: text/html
Last-modified: Sun, 07 Apr 1996 23:58:56 GMT
Content-length: 9123
CS 110 Section 2 - Program #2
Program #2 - Marathon
- Due Date:
- Friday 4/19/96, 8:50 am
- Grade:
- 25% of your final grade.
- Text Covered:
- Chp. 1, 2, 3 and 4.
- Background:
- On June 22 your gallant CS 110 instructor will be running his second marathon - the annual Grandma's Marathon in Duluth, Minnesota. If you're not familiar with what a marathon is, in ancient Greece in 490 BC a soldier ran from the town of Marathon to Athens to bring news of a Greek victory over the Persians. [Aside: why this news was so important that he ran the entire distance non-stop instead of leasurely taking his time and stopping to celebrate with the odd amphora of wine along the way is a topic of much historical debate]. The Marathon-Athens distance is actually less than 25 miles; the modern distance of 26 miles 385 yards (26.2 miles) was established in 1908 at the London Olympics and represents the distance from the royal castle at Windsor to the Olympic stadium. Although the marathon is considered the highlight and final track and field event of the Summer Olympic Games, there are no men's and women's records for this event because each course is different.
- Problem Description:
- You have been hired by the Grandma's Marathon Organizing Committee to write the computer software for processing the finishing times for this year's event. At the finish line the name and finishing time of each runner is entered into a computer. Your program will read in these values for all the runners and compute various statistics about the race, including the fastest two times.
Your program should first prompt the user to enter the total number of runners in the marathon and then prompt them to enter the name and finishing time of each runner entered on the same line as shown below.
'Name' Hours Minutes Seconds
For example,
5
'Ima Slug' 7 55 24
'Oprah Winfry' 3 8 16
'Hillary Clinton' 4 11 45
'Clark Kent' 1 5 10
'Gareth Bestor' 3 36 2
Notes:
- The name is entered as a CHARACTER string surrounded by single quotes and is at most 20 characters long.
- The finishing time is entered as three INTEGERs separated by spaces.
- Runners are entered in no particular order. In particular, they are not entered in ascending or descending order of finishing times.
- There will always be at least two runners.
Your program must read in all this data and compute the following statistics:
- Total number runners.
- Name of the first place runner.
- Name of the second place runner.
- Average finishing time displayed in Hours:Minutes:Seconds format.
- Standard deviation of finishing times displayed in Hours:Minutes:Seconds format.
- Average pace measured in minutes per mile and displayed in Minutes:Seconds format.
- Example:
- For the race data given above your program should display (hint: use this to check your results)
Total number of runners: 5
First place: Clark Kent
Second place: Oprah Winfry
Average finishing time: 3: 59: 19
Standard Deviation: 2: 29: 28
Average pace: 9: 8 minute/mile
Don't worry if you get extra spaces in your output as shown above. Optional Exercise: use formatted output as described in Chapter 5 to remove these spaces.
- Calculations:
- For most of the calculations you have to first convert the finishing times from Hours:Minutes:Seconds format to the total number of seconds. For displaying some of the results, such as the average finishing time, standard deviation and average pace, you will have to convert a value in total number of seconds back into Hours:Minutes:Seconds. Hint: you may find the MOD function useful for converting a value from total number of seconds to hours, minutes and seconds. All your results must be dislayed as INTEGERs rounded to the nearest second.
- To determine the first and second place winners you must remember the lowest and second lowest finishing times (in total number of seconds) and the corresponding names. Then each time you read in a new runner check to see if their time is less than either of these values and re-assign them accordingly.
- To compute the average finishing time first add up all the finishing times (in total number of seconds). To compute the standard deviation add up all the finishing time values squared. When you have obtained these two sums use the following formulae to compute the mean and standard deviation, where n is the total number of runners.
Although you will compute the mean and standard deviation in total number of seconds, they must be displayed in Hours:Minutes:Seconds format as INTEGERs rounded to the nearest second.
- Runners typically measure their pace in minutes per mile (minute/mile) which is the average number of minutes it takes to run one mile. Use the following formula to compute the average pace. The pace must be displayed in Minutes:Seconds format as INTEGERs rounded to the nearest second.
- What to Hand In:
- Hand in this assignment online by copying your FORTRAN source code file "program2.for" and the compiled executable file "program2.exe" to your handin directory.
You also have to hand in a printed copy of your FORTRAN source code file and a printed copy of the output when your program is run with the five different sets of test data given in the gradesheet.
- Gradesheet:
- The following gradesheet will be used to grade this assignment. Please take a close look at it to make sure you do everything that is required. Note that you will be graded on correct output for the five different sets of input values given below, so before handing it in you must run your program with these values and manually check that your program gives the correct results in all cases. You must enter each runner in the order given.
Correct Output [20]
5 [4]
'Julie Lewis' 4 12 19
'John Wiley' 2 18 55
'Gareth Bestor' 3 36 2
'Barbara McQueen' 3 41 9
'Diane Meyers' 2 33 17
3 [4]
'Julie Lewis' 4 12 19
'Barbara McQueen' 3 41 9
'John Wiley' 2 18 55
3 [4]
'John Wiley' 2 18 55
'Barbara McQueen' 3 41 9
'Julie Lewis' 4 12 19
5 [4]
'Julie Lewis' 5 12 19
'John Wiley' 3 18 55
'Gareth Bestor' 4 36 2
'Barbara McQueen' 4 41 9
'Diane Meyers' 3 33 17
5 [4]
'Diane Meyers' 2 55 34
'John Wiley' 3 53 9
'Barbara McQueen' 4 24 38
'Julie Lewis' 2 22 46
'Gareth Bestor' 3 36 2
User Interface [6]
Useful prompts for the total number of
runners and the data for each runner [2]
Meaningful display of the results [4]
Implementation [16]
Correct implementation of formulas [4]
Correct use of IF/THEN/ELSE/END IF statement [4]
Correct use of DO/END DO loop [4]
Meaningful variable names [2]
Indenting and neatness [2]
Documentation [8]
Program description [4]
Variable definitions and section comments [4]
____________________________________________________________
Total (25%) [50]