Answer to Question #252151 in C++ for saliha

Question #252151

A car completes its journey in three parts. It travels the first X km of its journey at an average

speed of x_Speed m/s and the next Y km at an average speed of y_Speed km/h. The car completes the

last part of its journey at an average speed of z_Speed km/h in z_Minutes minutes. Here X, x_Speed, Y,

y_Speed, z_Speed, and z_Minutes are all variables whose values you will have to take as an input from the

user. Find the average speed for its entire journey, giving your answer in km/h.


speed =

distance

time


1
Expert's answer
2021-10-16T11:02:22-0400
#include<iostream>
using namespace std;
int main(){
double	X, x_Speed, Y, y_Speed, z_Speed,  z_Minutes;
cout<<"Enter X (KM): "<<endl;
cin>>X;
cout<<"Enter x_Speed (m/s): "<<endl;
cin>>x_Speed;
cout<<"Enter Y (km): "<<endl;
cin>>Y;
cout<<"Enter y_Speed (km/h):  "<<endl;
cin>>y_Speed;
cout<<"Enter z_Speed (km/h):   "<<endl;
cin>>z_Speed;
cout<<"Enter z_Minutes:   "<<endl;
cin>>z_Minutes;
double num = (X + Y )+((z_Speed*z_Minutes) / 60);
double deno = (5 * X) / (18 * x_Speed) + (Y/y_Speed) + (z_Speed/60);
double speed = num / deno;
cout<<"Total distance is:  "<<num<<endl;
cout<<"Total time taken is:  "<<deno<<endl;
cout<<"Average speed is:   "<<speed<<endl;


	
	
}

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