So J/5 = 3M/4
Then if J' is the amount that John had after the buying and selling, and M' is the amount Mark had after buying and selling, then the 5:3 ratio tells us that
3J'/8 = 5M'/8
We also know that J' = J - 150
and M' = M + 160.
So if we replace J' and M' with those
So we have two simultaneous equations with two unknowns: