Let's say that the speed of the freight train is and the one of the passenger train is .
MPH means every hour the freight train covers miles., which means in 3h it will have covered 3 times as much: mi.
Following the same logic, MPH means every hour the passenger train covers miles, meaning after 3h it will have covered 3 times as much as well: mi.
Now, having expressed those distances and speeds algebraically, we find the difference between the two distances covered after 3h, knowing it will be equal to 240:
Knowing this, we can surely affirm that the freight train is travelling at 40MPH and the passenger train is travelling three times as fast, 120MPH.