Create a class runnerdata that creates a formatted file


A local running group held a one hour track event where people tried to complete as many miles as they could in one hour. The times were recorded and saved in a file. Each line of the file represents a runner and each line contains 10 entries. The entries are the number of seconds it took to the runner to complete that mile.

An entry of zero means the runner didn't finish that mile. You may assume the file will never have more than 20 runners. An example file might look like

372 368 375 380 381 383 390 382 380 0
352 355 357 359 358 361 365 362 362 360
575 572 570 569 572 570 0 0 0 0

Create a class, RunnerData, that creates a formatted file that displays the mile times in "minutes:seconds" format and adds an extra column at the end with the average mile time for the runner. If the runner didn't complete a mile, the entry should be empty. The above example input would generate the following output

6:12 6:08 6:15 6:20 6:21 6:23 6:30 6:22 6:20 | 6:19
5:52 5:55 5:57 5:59 5:58 6:01 6:05 6:02 6:02 6:00 | 5:59
9:35 9:32 9:30 9:29 9:32 9:30 | 9:31

Your solution should have three methods:

// Reads the data from the specified file and stores it in the supplied table.
// filepath : a path to the file containing the data
// runnerData : the array to store the data read from the file
//
// The method returns the number of runners (rows) found in the file.
//
private static int importData(string filepath, int[][] runnerData);

// Outputs a table including runner average.
// filepath : a path to the file where the table should be written
// runnerData : the array containing the mile times in seconds
// runnerCount : the number of rows of data in the table
//
private static void exportTable(string filepath, int[][] runnerData, int runnerCount);

// This function will load data from a file called "input.txt" and output to a file
// called "output.txt".
//
public static void main(String[] args);

The main() method will not be very involved. It will likely consist of the declaration of a handful of variables and then simply calling the import and export functions. Your program should not interact with the user.

The input file could have any number of lines, but all lines will contain 10 values.

Solution Preview :

Prepared by a verified Expert
JAVA Programming: Create a class runnerdata that creates a formatted file
Reference No:- TGS02710327

Now Priced at $10 (50% Discount)

Recommended (95%)

Rated (4.7/5)