Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

A group of AU friends decide to run the Banff, Alberta, Marathon. Their names, t

ID: 3600932 • Letter: A

Question

A group of AU friends decide to run the Banff, Alberta, Marathon. Their names, times (marathon completion time in minutes), and number of years participated are given below:

1

Elena Brandon

341

1

2

Thomas Molson

273

2

3

Hamilton Winn

278

5

4

Suzie Sarandin

329

7

5

Philip Winne

445

9

6

Alex Trebok

275

3

7

Emma Pivoto

275

4

8

John Lenthen

243

1

9

James Lean

334

1

10

Jane Ostin

412

1

11

Emily Car

393

4

12

Daniel Hamshire

299

4

13

Neda Bazdar

343

3

14

Aaron Smith

317

6

15

Kate Hen

265

8

Extend the AddressBook class from Problem 1 to store the additional data. Now, write a method to find the fastest runner. Print the name, address, and his/her time (in minutes) on three separate lines.

Find the second fastest runner. Print the name, address, his/her time (in minutes), and the difference in time with the fastest runner.

Compute the average time of completion taken by these runners.

Finally, print the name and number of years participated for each runner if the runner’s time of completion is equal to or better than the average time of completion.

1

Elena Brandon

341

1

2

Thomas Molson

273

2

3

Hamilton Winn

278

5

4

Suzie Sarandin

329

7

5

Philip Winne

445

9

6

Alex Trebok

275

3

7

Emma Pivoto

275

4

8

John Lenthen

243

1

9

James Lean

334

1

10

Jane Ostin

412

1

11

Emily Car

393

4

12

Daniel Hamshire

299

4

13

Neda Bazdar

343

3

14

Aaron Smith

317

6

15

Kate Hen

265

8

BanffMarathonRunner Attributes + private int time + private int years E Operations + public BanffMarathonRunner(String fn, String In, int min, int yr) + public int getTime0 + public int getYearsO + public static BanffMarathonRunner getFastestRunner(BanffMarathonRunner] runners) + public static BanffMarathonRunner getSecondFastestRunner(BanffMarathonRunner] runners) +public static d +public static String getAboveAverageRunners(BanffMarathonRunner[] runners) + public void setTime(int time) +public void setYears(int years)

Explanation / Answer

firstly we include the headers file for run or execution of our program.

#include<iostream.h>

#include<conio.h>

class addressbook //make a address class to store theadress feature
{
public:
char name[15];
char add[15];
doble time[15]:
int years[15];

void get() //to input the address part of the calss
{
int i;
for(i=0;i<15;i++) //for taking the inputs of the fifteen players
{
cout<<" the name of the player:";
cin>>name;
cout<<" the address of the player:";
cin>>add;
cout<<" the time of the player:";
cin>>time;
cout<<" the no of years participated by the players :";
}
}

void sorted() //arrange the data in ascending order
{
int temp;
temp=time[0];
for(i=0;i<15;i++)
{
for(j=0;j<=i;j++)
{
if(time[i]>time[j])
{
time[i]=time[j];
time[j]=temp;
temp=time[j+1];
}
}
}

void rank() // find the first two rank
{ int r;
cout<<" the fastest runner is:"<<time[0];
cout<<" the name of fastest player is:"<<name[0];
cout<<" the address of fastest player is :"<<add[0];
cout<<" the no of years played by fastest palyer is :"<<time[0];


cout<<" the second runner is:"<<time[1];
cout<<" the name of second player is:"<<name[1];
cout<<" the address of second player is :"<<add[1];
cout<<" the no of years played by second palyer is :"<<time[1];

r=time[1]-time[0];
cout<<"the diffrence of time between the fastest and second player is:" <<r;
}


void avg() //for average time
{
int avg;
avg=(time[0]+time[1]+time[2]+time[3]+time[4]+time[5]+time[6]+time[7]+time[8]+time[9]+time[10]+time[11]+time[12]+time[13]+time[14])/15
cout<<" the average time is:"<<avg;

for(i=0;i<15;i++)
{
if(time[i]>avg)
{
cout<<" name:"<<name[i];
cout<<" no of years:"<<year[i];
}
}

};

void main()
{
clrscr();
addressbook a; //creating a object of class to access the member function of the class
a.get();
a.sorted();
a.rank();
a.avg();
getch();
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote