Answer to Question #255271 in C++ for Prince

Question #255271
Write a C++ program to calculate the elapsed time it takes to make a 783.67-mile trip. The equation for computing elapsed time is elapsed time = total distance / average speed. Assume that the average speed during the trip is 60 miles per hour.
1
Expert's answer
2021-10-22T16:47:06-0400
#include <iostream>
using namespace std;

int main()
{
	double distance = 783.67;
	double aver_speed = 60;
	double elaps_time = distance / aver_speed;
	int el_time_in_sec = elaps_time * 3600;
	int hour = elaps_time;
	int sec = (elaps_time - hour) * 3600;
	int min = sec / 60;
	sec = sec - min * 60;
	cout << "Elapsed time, that takes to make 783.67-mile trip is\n"
		<< elaps_time << " hours or\n" << el_time_in_sec << " seconds or \n"
		<< hour << " hours " << min << " minutes " << sec << " seconds ";
}

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

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS