lol, the question was asked as essentialy a thought experiment to an intro to physics.
It is, a think outside the box question, obviously intended to be such if you havent surmised using the variables of a fly and locomotive. Again, zen labels meaning nothing in the setup of a story problem.
The first step mathematically is to turn those labels into an equation, that is the mathematic approach, common sense does not come into play given this thinking and would be the cognitive out for the professor if he disagreed but you'd have to write this up to shut that out too to PROVE, that what you turn in, is the only correct logical answer.
It does not matter how fast flies can fly, b/c no one has ever seen a fly fly its fastest given the heisenberg uncertainty principle, if all the electrons of the fly happen to move all forward in one direction, itll fly faster than you could even conceive
So, in effect, lets mathematically attack the issue with the theory of relativity. If, as the fly Matt points out approaches light speed, we know, that the theory says its mass would increase, therefore needing more energy to propel its mass, the problem with all scifi ideas of travelling light speed. ITs A LAW. AS YOU NEAR INFINITE SPEED, MASS MOVES TOWARDS INFINITY REQUIRING INFINITE AMOUNTS OF ENERGY TO PROPEL IT. Travelling the speed of light is impossible with the limits of modern thought, although, I have more theories on this but, to accepted professors.
SImply move the fly up to lightspeed, moving its mass til it equals the mass of the locotomotive according E=MC2 and then match the two velocites and they should cancel each other's kinetic energy. Thereby, answering the question and shutting up the professor who wanted to fuck with his students heads