Question: In the a walkthrough video in Module 1 , we created an algorithm that determined how long it takes two trains to crash. That walkthrough

In the a walkthrough video in Module 1, we created an algorithm that determined how long it takes two trains to crash. That walkthrough assumed that the trains were always headed towards each other and would crash for the sake of simplicity. Now that we know about conditionals redesign that algorithm to remove that restriction.
Your algorithm should be named determine_crash, and it must take three inputs -- the two train velocities in meters per second and the starting distance between them in kilometers -- and display either "The trains are fine!" or "Crash in TIME minutes!" depending on if the trains will crash.
To help orient yourself, consider the velocity's sign as the direction of travel. When the velocity is positive, we are going east (or rightward); when negative, we are going west (or leftward). Assume that the first train (train A) will always start to the west (on the left side) of the second train (train B). We can reduce all of the logic in determining if a train will crash to these statements. The trains will collide only if one of following are true:
A and B go east and A is faster than B.
A and B go west and B is faster than A.
A and B head towards each other.
After planning, work on your black-box tests. Remember! We have to test all of the ways a condition can be true or false in order to be complete! Your algorithm must work for all numeric inputs.
The following are some tests you can use to build confidence.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!