Two trains and a fly

You can use this applet to explore the following classic problem - Two trains [each shown with a green dot] that are D miles apart travel toward each other along the same track. Each train travels at V miles per hour. A fly is hovering just above the nose of the first train. It buzzes from the first train to the second train, turns around immediately, flies back to the first train, and turns around again. The fly goes on flying back and forth between the two trains until they collide. If the fly's speed is v miles per hour, how far will does the fly travel?