Answer to Question #294355 in C++ for Yacci

Question #294355

A man walks 7 km in 2 hours and 2 km in 1 hour in the same direction.a) What is the man's average speed for the whole journey?Create a program that will automatically compute for the man’s average speed. Use function in designing the program. The formula on how to get the speed is speed = distance / time

1
Expert's answer
2022-02-06T02:14:15-0500


#include <iostream>


using namespace std;




float calculateSpeed(float distance,float time){
	float speed = distance / time;
	return speed;
}


int main() {
	float averageSpeed=(calculateSpeed(7.0,2.0)+calculateSpeed(2.0,1.0))/2.0;
	cout<<"The man's average speed for the whole journey: "<<averageSpeed<<" km/hour\n\n";
	cin>>averageSpeed;
	return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment