Question: I want the put the dataset.txt in my program so it will read the information because right now it is not. This is the code

 I want the put the "dataset.txt" in my program so it

will read the information because right now it is not. This is

I want the put the "dataset.txt" in my program so it will read the information because right now it is not. This is the code from the previous question.

#include #include #include #include #include #include

using namespace std;

class Racer{

// private members private: int bib; string name; double distance; string time; double avg; public:

// constructor Racer(){ bib=0; name=""; distance=0.0; time=""; avg=0.0; }

// constructor with arguments Racer(int a,string b,double c,string d){ bib=a; name=b; distance=c; time=d;

string h,m,s;

// calculate average time

h=d.substr(0,1); m=d.substr(2,2); s=d.substr(5,2);

stringstream _s(s); stringstream _h(h); stringstream _m(m);

int __h=0,__m=0,__s=0; _h>>__h; _m>>__m; _s>>__s;

double t=__h+.6*__m+.36*__s;

avg=c/t; }

// setter function void setBib(int a){ bib=a; }

void setName(string a){ name=a; }

void setDistance(double a){ distance=a; }

void setTime(string a){ time=a; }

// getter function int getBib(){ return(bib); }

string getName(){ return(name); }

double getDistance(){ return(distance); }

string getTime(){ return(time); }

double getAvg(){ // calculate time

string h,m,s;

h=time.substr(0,1); m=time.substr(2,2); s=time.substr(5,2);

stringstream _s(s); stringstream _h(h); stringstream _m(m);

int __h=0,__m=0,__s=0; _h>>__h; _m>>__m; _s>>__s;

// time with point notation double t=__h+__m/60.0+__s/3600.0;

avg=distance/t;

return(avg); } };

// display result

void disp(Racer *r,int n){

cout

for(int i=0;i

// sorting uding bib

void dispBib(Racer *r,int n){ Racer *tmp=new Racer[n];

for(int i=0;i

int i,j; Racer k;

for(i=0;i

while(j>=0 && tmp[j].getBib()>k.getBib()){ tmp[j+1]=tmp[j]; j--; }

tmp[j+1]=k; }

// display result disp(tmp,n); }

// sorting by distance // if equal then use time

void dispDisTime(Racer *r,int n){ Racer *tmp=new Racer[n];

for(int i=0;i

int i,j; Racer k;

// sort by distance then time

for(i=0;i

bool b=false;

if(tmp[j].getDistance()

// if display is equal if(tmp[j].getDistance()==k.getDistance()){ if(tmp[j].getTime()>k.getTime()){ b=true; } } }

while(j>=0 && b==true){ tmp[j+1]=tmp[j]; j--; }

tmp[j+1]=k; }

// display

disp(tmp,n); }

// search for bib number by name

int searchBib(Racer *r,int n,string s){ int ret=-1;

int c=0;

// BST

while(c

return(ret); }

// search by bib value

int searchName(Racer *r,int n,int b){ int ret=-1;

int c=0;

// BST

while(c

return(ret); }

// menu

int menu(){ cout

int ret=0; cin>>ret;

return(ret); }

// main function

int main(int argc,char** argv){

Racer *racerList=new Racer[100]; int count=0;

ifstream in; in.open(argv[1]);

if(!in){ cout

// read file while(!in.eof()){

in>>a; in>>b1; in>>b2; in>>c; in>>d;

racerList[count].setBib(a); racerList[count].setName(b1+" "+b2); racerList[count].setDistance(c); racerList[count].setTime(d);

count++; } }

// menu anf display action while(true){ int m=menu();

if(m==1){ dispBib(racerList,count); } if(m==2){ dispDisTime(racerList,count); } if(m==3){ cout

if(ret!=-1){ cout

if(m==4){ cout>b; int ret=searchName(racerList,count,b);

if(ret!=-1){ cout

return(0); }

Problem: Write a C++ program that will allow a user to access the results from a time-trial bike race. The race consists of laps around a 6.1 mile course, and the racers try to complete as many laps as they can within 6 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: 1) Bib number - a positive integer 2) Racer's name - a string (may include spaces) 3) Distance covered by the racer (equal to the number of laps completed times 6.1) 3) Recorded time - a string in "05:23:32" 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 "dataset.txt". It will contain up to 100 results. See the sample file on the class website. Then, it should offer the user a menu with the following options: 1. Display Results sorted by bib number 2. Display Results sorted by distance, then time 3. Lookup a bib number given a name 4. Lookup a result by bib number 5. Quit the Program The program should perform the selected operation and then re-display the menu. Do not change the menu numbers associated with the operations. Display an error message if the user enters an inappropriate number. For options 1 and 2, display the results for each racer on a single, separate line. The results should include the Bib number, the name, the distance, the time, and the average speed in miles per hour (distance/time in hours). The values should line up in columns (use setw). Headers for the table are optional. For options 3, output the bib number with a label, and for option 4, output the results for the racer on a single line. For options 3 and 4, if the racer is not found display an appropriate message. Problem: Write a C++ program that will allow a user to access the results from a time-trial bike race. The race consists of laps around a 6.1 mile course, and the racers try to complete as many laps as they can within 6 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: 1) Bib number - a positive integer 2) Racer's name - a string (may include spaces) 3) Distance covered by the racer (equal to the number of laps completed times 6.1) 3) Recorded time - a string in "05:23:32" 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 "dataset.txt". It will contain up to 100 results. See the sample file on the class website. Then, it should offer the user a menu with the following options: 1. Display Results sorted by bib number 2. Display Results sorted by distance, then time 3. Lookup a bib number given a name 4. Lookup a result by bib number 5. Quit the Program The program should perform the selected operation and then re-display the menu. Do not change the menu numbers associated with the operations. Display an error message if the user enters an inappropriate number. For options 1 and 2, display the results for each racer on a single, separate line. The results should include the Bib number, the name, the distance, the time, and the average speed in miles per hour (distance/time in hours). The values should line up in columns (use setw). Headers for the table are optional. For options 3, output the bib number with a label, and for option 4, output the results for the racer on a single line. For options 3 and 4, if the racer is not found display an appropriate message

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!