Question: C + + Please Bicycle Race Results Problem description: Write a C + + program that will allow a user to access the results from
C Please
Bicycle Race Results
Problem description:
Write a C program that will allow a user to access the results from a
timetrial bike race. The race consists of laps around a mile course, and
the racers try to complete as many laps as they can within hours. Only
complete laps count. Your program will read in the race results from a file
and display the data in the format requested
Your program will be provided with a dataset in a file containing the
following information for each racer:
Bib number a positive integer
Racers name a string may include spaces
Distance covered by the racer equal to the number of laps
completed times
Recorded time a string in :: format The number of laps is
not provided and does not need to be computed.
The program should first read the results from a text file named
datasettxt It will not contain more than racer's results. A sample of
this file is available in Downloadable files.
Then, it should offer the user a menu with the following options:
Display Results sorted by bib number
Display Results sorted by distance, then time
Lookup a bib number given a name
Lookup a result by bib number
Quit the Program
The program should perform the selected operation and then redisplay the
menu. Display an error message if the user enters an inappropriate
number.
For options and display the results for each racer on a single, separate
line. The results should include the Bib number, the name, the distance,
and the time. The values should line up in columns
For option output the bib number and for option output the results for
the racer on a single line. For options and if the racer is not found,
display an appropriate message.
See sampleexecution.txt in the Downloadable files. In order to get full
grades, your output will need to match exactly.
Additional Requirements:
Your program should contain a structure called Result with the following
fields:
bibNumber integer number
name a string
distance a double
time a string
Important: Don't change field namesdata types or their order. You'll not be
able to pass all tests otherwise.
Use a partially filled array of structures to store the results. Use a counter
variable to count the number of results that are read in from the file, and
use this value as the size of the array for the search and sort functions.
Aside from main function your program should have at least these
functions:
void readDatasetifstream& in Result results int &size;
void displayDatasetResult results int size;
int linearSearchByNameResult results int size, string targetName;
int binarySearchByNumberResult results int size, int targetNumber;
void sortByNumberResult results int size;
void sortByDistanceTimeResult results int size;
readDataset. Should read results into results array from the in file
stream opened in main Updates size.
displayDataset. Should nicely print results array see "Tips" section
linearSearchByName. Should find the index of a racer's result by their
name using a linear search. If no such racer exist return
binarySearchByNumber. Should find the index of a racer's result by
their bib number using a binary search.
If no such racer exist return
sortByNumber. Should sort results by bibNumber field in ascending
order. Must use bubble sort or selection sort algorithm.
sortByDistanceTime. Should sort results by distance descending
and if two racers have the same distance they should be ordered by
time in ascending order. Must use bubble sort or selection sort
algorithm.
Important: Don't change function names, parameterreturn data types.
Do not use a library sort function or comparators to sort the data. Modify
the code included in Downloadable files.
Tips:
You can use the following function to print the menu:
void displayMenu
cout
Menu
;
cout Display Results sorted by bib number
;
cout Display Results sorted by distance, then time
;
cout Lookup a bib number given a name
;
cout Lookup a result by bib number
;
cout Quit the Program
;
cout "Enter your choice
You can use the following function to display a header for the results
table. Use a modified version of the cout statement to output each line of
the results.
void displayHeader
cout left
setw "BibNum"
setw "Name"
right
setw "Distance"
setw "Time
endl;
The Downloadable files section includes the following. Please look at this
code before you start implementing your program! Examples
dataset.txt
sampleexecution.txt
menu.cpp
BinarySearch.cpp
BubbleSort.cpp
LinearSearch.cpp
SelectionSort.cpp
readFile folder
SuggestedDevProcess.pdf
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
