Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Triathlon Timing A triathlon is a competition between individuals consisting of a swim, followed by a bike, followed by a run. Depending on the level

image text in transcribed

Triathlon Timing A triathlon is a competition between individuals consisting of a swim, followed by a bike, followed by a run. Depending on the level of the competition, the lengths of each of these legs of the competition vary. Macon has decided to hold its first local triathlon and wants to hire a computer science student to make predictions about how the contestants will fare, based on their previous races. The distribution of these expected finish times will help the city plan for providing water and other help for contestants during and after the competition. The information you will have about each contestant is their average speed swimming, biking and running, in miles per hour. Help the city by writing a program to calculate the expected finish times for all of the competitors. Sort your list by finish time. If two competitors tie, break the tie followed by age, with the younger competitor going first. If this doesn't break the tie, break it by a comparison of last names, alphabetically, followed by first names. Note that two finish times are considered a tie only if the difference between them is less than 10-10 hours. You are guaranteed that all competitors will have unique names so that there's only one correct sorted list. Input The first line of the input file will contain a single positive integer, n, representing the number of races for which to make predictions. Data for each of the n races follows. The first line of data for each race will contain a positive integer, c (c 10), representing the number of competitors in the race, followed by three positive real numbers with exactly one digit after the decimal, representing the number of miles for the swim, bike and run, respectively. Each of these four pieces of information will be separated by a single space. The following c lines of input for each case will have information about one contestant in the race. Each of these lines will contain the last name of the contestant (1-20 uppercase letters), followed by the first name of the contestant (1-20 uppercase letters), followed by a positive integer representing the competitors age, followed by the competitor's speed, in miles per hour for the swim, bike and run, respectively. Each of the last three values on a line will be given as a real number to exactly 2 decimal places. Output For each race, output a single line with the following header: Race k: where k is the number of the race, starting with 1. On the following lines, put the name of the competitors in order, with their last name, followed by their first name, followed by their expected finishing time, in hours, rounded to three decimal places. Order the list as previously described. Follow the output for each case with a blank line. Sample Input 2 3 1.0 100.0 10.0 JONES BOB 33 2.00 25.00 10.00 JONES ALLISON 33 1.00 50.00 4.00 ROSS SHELLY 40 3.00 40.00 15.00 2 2.0 50.0 5.0 WASHINGTON GEORGE 281 1.00 10.00 5.00 ADAMS JOHN 277 1.00 12.50 2.50 Sample Output Race 1: ROSS SHELLY 3.500 JONES ALLISON 5.500 JONES BOB 5.500 Race 2: ADAMS JOHN 8.000 WASHINGTON GEORGE 8.000

Triathlon Timing decimal plao Sample lspat 2050 2.5

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing

Authors: David M. Kroenke, David Auer

11th Edition

B003Y7CIBU, 978-0132302678

More Books

Students also viewed these Databases questions