To solve this the Neumann's way, we calculate the time the fly takes in each of its Trips between $A$ and $B$.
Trip $1$ From $A$ to $B$:The fly travels at $100$ kph from $A$ towards the train coming from $B$ at $40$ kph. That means, it is traveling at a relative speed of $140$ kph and it has to cover a distance of $180$ km to meet the train coming from $B$. Time it takes for this Trip $1$ is $(9/7)$ hr. Let us call this $T_1$.
Trip $2$ From $B$ to $A$: In this Trip, the fly does not cover the complete distance of $180$ km, since each train would have covered $(40)*(9/7)$ km by the time the fly completes its Trip $1$. So, the distance the fly has to cover in Trip $2$ is $(180) -(40)*(9/7) -(40)*(9/7)$, which is equal to $(180)*(3/7)$ km. In this Trip, the fly is again traveling at a relative speed of $140$ kph towards the train coming from $A$. Time it takes for this Trip $2$ is $(180)*(3/7)*(1/140)$, that is, $(9/7)*(3/7)$ hr. Let us call this $T_2$.
Continuing the same way, we get
$T_3$ for Trip $3$ From $A$ to $B$ = $(9/7)(3/7)^2$
$T_4$ for Trip $4$ From $B$ to $A$ = $(9/7)(3/7)^3$
And so on. (Remember, the distance the fly covers keeps decreasing from Trip to Trip.)
The total time the fly takes between the trains is:
$(9/7)+(9/7)*(3/7)+(9/7)*(3/7)^2+(9/7)*(3/7)^3+(9/7)*(3/7)^4.......$
The sum to infinity of this Geometric Series is equal to $9/4$ or $2.25$ hrs.
At $100$ kph, the fly therefore travels a total distance of $225$ km.