Question

2) The following table gives data for the distance traveled along five truck routes and the corresponding time required to tr

c++

0 0
Add a comment Improve this question Transcribed image text
Answer #1

hello,

providing you the code for your problem:-

code starts here:-

#include<iostream>
using namespace std;
int main()
{
int route[]={1,2,3,4,5};
int distance[]={560,440,490,530,370};
float duration[]={10.3,8.2,9.1,10.1,7.5};
float max=0.0;
int route_max;
cout<<"Route"<<"\t"<<"Avg Speed(mi/hr)"<<endl;
for(int i=0;i<5;i++)
{
    if((float)(distance[i]/duration[i])>max)
    {
        max=(float)(distance[i]/duration[i]);
        route_max=i+1;
    }
    cout<<i+1<<"\t"<<(float)(distance[i]/duration[i])<<endl;
}
cout<<"route "<<route_max<<" has the highest average speed of "<<max<<" mi/hr";
}

code ends here:-

providing you the output snapshot :-

Route Avg Speed (mi/hr) 54.3689 53.6585 53.8462 52.4752 49.3333 route i has the highest average speed of 54.3689 mi/hr

i hope i was able to solve your problem to a greater extent, please feel free to comment your queries, Please consider my efforts and upvote my solution.

Thanku:)

Add a comment
Know the answer?
Add Answer to:
c++ 2) The following table gives data for the distance traveled along five truck routes and...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT