Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Description Two cars A and B leave an intersection at the same time. Car A travels west at an average speed of x (int) miles
Description Two cars A and B leave an intersection at the same time. Car A travels west at an average speed of x (int) miles per hour and car B travels south at an average speed of y (int) miles per hour. Write a program that prompts the user to enter the average speed of both cars and the elapsed time (in hours and minutes, both will be int types) and then outputs the (shortest) distance between the cars (double). Specifications Make sure to comment your code (comment all of your variables and parts of your code that performs a specific task) Give your variables meaningful names Make sure you use the correct types for your variables Sample Output $ g++ Assignment02. cpp $ ./a.out Enter the speed of Car A and car B: 88 85 Enter elapsed time (hours and minutes): 1 24 The two cars are 171.287 miles apart from each other $ ./a. out Enter the speed of Car A and car B: 55 107 Enter elapsed time (hours and minutes): 0 1 The two cars are 2.00513 miles apart from each other $ ./a.out Enter the speed of Car A and car B: 199 199 Enter elapsed time (hours and minutes) 2 30 The two cars are 703.571 miles apart from each other
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started