A+ Work





The CSIT Racing Club is a group that runs amateur car racing events throughout the US. In This project, write a program that will help the club determine the winner of their Fall Rally Race. You will need to determine each racer’s average time and identify the first place finisher. An input file with race information contains records of all the laps run by each driver. The record for each driver includes the number of the car the driver races and times for each of 8 laps run during the race. For the record of each driver, your program should determine the average lap time based on the following rules:

a. Each driver’s slowest two lap times are discarded before the average is calculated

b. Any driver that has a lap time that is recorded as a negative number means that the driver incurred a penalty and is disqualified from the race (so no average needs to be calculated). Your program also needs to determine the numbers of qualified and disqualified drivers.

The program has to ask the user for the input file name first, and then read the data into your program. After that, calculate the average lap time. Furthermore, the program has to decide the first place finisher. If two or more drivers have the exact same best record, you have to display all of them as the first place finishers. In this program, you can assume that the total number of drivers entered into the race will not be greater than 30

Sample Input File

The following shows a sample input data file. The first line has the number of drivers. Each

line indicates the racer’s number and 8 lap times.

5

42 5.6 6.2 3.6 4.5 5.5 4.56 3.75 4.65

8 4.9 5.5 4.8 5.75 4.6 5.6 6.2 6.3

16 5.6 6.2 3.6 -4.5 4.6 5.6 6.2 6.3

75 4.7 8.5 2.6 3.4 5.5 4.56 3.75 4.65

10 5.6 6.2 3.6 -5 -7 4.56 3.75 4.65

Sample Run

A sample run of your program might look like this. Note that the user’s inputs are

highlighted in bold.

Enter an input file: C:\\Temp\\rally.txtCST231 Page 2 of 2 Project 2

---------------------------------------------------

Rally Race Result

---------------------------------------------------

Racers Avg. Lap

42 4.43

8 5.19

16 DQ

75 3.94

10 DQ

---------------------------------------------------

First Place: Racer 75 (Avg. Lap: 3.94)

Number of Qualified Racers: 3

Number of Disqualified Racers: 2

Design and Implementation

You must develop your program with the following two functions or more.

1. A function to read a data file and calculate the average lap times: This function should

prompt the user a data file name and read the data. Then it calculates the average lap time

for each driver.

2. A function to print the race result and determine the top finisher.

For this project, you may need several arrays to store the ids of drivers and results.

Additionally, it may need to pass the arrays between functions.