Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

cpp A group of students decided to run in the Columbus Marathon. Their names and times (in minutes) are below: Name Time (minutes) Elena 341

cpp A group of students decided to run in the Columbus Marathon. Their names and times (in minutes) are below:

Name Time (minutes)

Elena

341

Thomas

273

Hamilton

278

Suzie

329

Phil

445

Matt

402

Alex

388

Emma

275

John

243

James

334

Jane

412

Emily

393

Daniel

299

Neda

343

Aaron

317

Kate

265

Find the fastest two runners.

In particular, write a program as follows. Print the list of runners and times as above. Then print the name of the fastest runner and his/her time (in hours and minutes). Also, find the second fastest runner. Print the name and his/her time (in hours and minutes).

The program must have a method that takes as input an array of integers and returns the index corresponding to the person with the lowest time. The Program must also have a second method to find the second-best runner. The second method can use the first method to determine the best runner, and then return the index corresponding to the person with the second lowest time.

Extra Credit (10 points): Print the list of runners and times nicely formatted in columns as displayed above.

Here is some program code to get started:

#include

#include

using namespace std;

int main (){

const int numRunners = 16;

string names[] ={"Elena", "Thomas", "Hamilton", "Suzie", "Phil",

"Matt", "Alex", "Emma", "John", "James", "Jane", "Emily", "Daniel",

"Neda","Aaron", "Kate"};

int times[] ={341, 273, 278, 329, 445, 402, 388, 275, 243, 334, 412,

393, 299,343, 317, 265};

. . .

for (int i = 0; i < numRunners; i++) {

cout << names[i] << ": " << times[i];

}}

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 Administrator Limited Edition

Authors: Martif Way

1st Edition

B0CGG89N8Z

More Books

Students also viewed these Databases questions