Question: Complete the following program by defining the function statistics(). The function statistics() finds and prints the fastest time as the best time, the slowest time

Complete the following program by defining the function statistics(). The function statistics() finds and prints the fastest time as the best time, the slowest time as the worst time, and computes the average of 5 times for each event. After this is completed, write a driver that uses the class. Your driver first asks a runner for a distance and 5 of his/her best times in that event, and it stores the times in the array time. Then it prints the best time, the worst time, and the average time for that runner. Finally, on a different line the driver displays the complete array of times.

class RunnerData { public: void set_distance(int d); void set_times(int i, double t); void display(); void statistics( ); private: double time[5]; //array of time in second int distance; //distance in meter double min, max, average; }; The member functions are defined as: void RunnerData::set_distance(int d) { distance = d; } void RunnerData::set_times(int i, double t) { time[i] = t; } void RunnerData::display() { cout << "Here is your best 5 times for "; cout << distance << " meter "; for(int i = 0; i < 5; i++) { cout << time[i] << endl; } }

Thanks in advance :)

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!