Question

In: Computer Science

Your car travels west at an average speed of x kilometers per hour and your friend’s...

Your car travels west at an average speed of x kilometers per hour and your friend’s car travels south at an average speed of Y Kilometers per hour. Write a C++ code that prompts the user to enter the average speed of your car and your friend’s car and the elapsed time in hours and minutes since the 2 cars started their movement, and output the shortest distance between the 2 cars.

Solutions

Expert Solution

#include <iostream>
#include <cmath>
using namespace std;
int main()
{
double x,y,hours,minutes;
cout<<"Enter the average speed of your car(KMPH): ";
cin>>x;
cout<<"Enter the average speed of your friend’s car(KMPH): ";
cin>>y;
cout<<"Enter the elapsed time in hours and minutes since the 2 cars started their movement: ";
cin>>hours;
cin>>minutes;
double xD=x*(hours+minutes/60.0);
double yD=y*(hours+minutes/60.0);
cout<<"Shortest distance = "<<(sqrt(xD*xD+yD*yD));
return 0;
}


Related Solutions

The speed limit of a road is 65 miles per hour. The speed of a car...
The speed limit of a road is 65 miles per hour. The speed of a car on the highway follows a normal distribution with a mean of 70 and standard deviation of 5. What percent of the distribution breaks the speed limit? The speed limit of a road is 65 miles per hour. The speed of a car on the highway follows a normal distribution with a mean of 70 and standard deviation of 5. A police officer will only...
Car A has a mass of 2000 kg and speed of 10 miles per hour. Car...
Car A has a mass of 2000 kg and speed of 10 miles per hour. Car B has mass of 1000 kg and speed of 30 miles per hour. The two cars collide to each other and stick together after collision in three different situations. Calculate the velocity of the two cars after the collision. 1. Car A moves East and car B moves West and had a head to head collision. Calculate the velocity of the two cars after...
What are the speed of recession, in kilometers per second, and redshift of a galaxy that...
What are the speed of recession, in kilometers per second, and redshift of a galaxy that is a distance of 183 megaparsecs (Mpc) away? Speed of recession? Redshift?
The following data represent the speed of a car (in miles per hour) and its breaking...
The following data represent the speed of a car (in miles per hour) and its breaking distance (in feet) on dry asphalt. Speed 30 40 50 60 70 80 Breaking Distance 66.3 82.3 100.5 121.2 142.3 160.7 b) Find the least squares regresssion line. Round the slope and y-intercept to two decimals. B(x) =    (c) Find the linear correlation coefficient. Round your answer to 4 decimals. r =    (d) Comment on whether a linear model is a good model. Explain...
A car traveling with constant speed travels 150 km in 7200 s. What is the speed of the car?
A car traveling with constant speed travels 150 km in 7200 s. What is the speed of the car? Express the speed with the appropriate units.
A researcher claims that the average wind speed in his city is 10 miles per hour....
A researcher claims that the average wind speed in his city is 10 miles per hour. In a random sample of 36 days, you found the average speed of wind is 10.2 with a standard deviation of 0.8 miles per hour. At α=0.05 is there enough evidence to say that the average is greater than the researcher’s claim. Show your work by using hypothesis testing.
The average annual wind speed in Rochester, Minnesota is 13.1 miles per hour. A sample of...
The average annual wind speed in Rochester, Minnesota is 13.1 miles per hour. A sample of 100 days is used to determine the average wind speed. Find the 98% confidence interval of the mean. Assume the standard deviation was 2.8 miles per hour.
You collect the following data on the average speed (in miles per hour) of a student driver on the highway:
You collect the following data on the average speed (in miles per hour) of a student driver on the highway:Speed68666982838275798679807977597372715173100738080677270676875666387726269587478736773798475656568786460857782867487100777175727276587663767266737983848678787764657868819286568483a.If you want to construct a 95% confidence interval, what would use for the t-critical value?b. what would be the lower boundof your 95% confidence interval?c. what would be the upper bound of your 95% confidence interval?
A car travels along a straight east-west road. A coordinate system is established on the road,...
A car travels along a straight east-west road. A coordinate system is established on the road, with x increasing to the east. The car ends up 19 mi west of the intersection with Mulberry Road. (A) If its displacement was -21 mi , how far from Mulberry Road did it start?
A car is moving at 55 miles per hour. The kinetic energy of that car is...
A car is moving at 55 miles per hour. The kinetic energy of that car is 5 × 105 J.How much energy does the same car have when it moves at 98 miles per hour? Answer in units of J
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT