Use conservation of momentum.
M = mass of cannon = 200 kg
m = mass of shell = 3 kg
u = recoil velocity of cannon = -5.1 m/s (Note the negative sign.)
v = speed of shell = ?
Initial momentum is zero, so final momentum must also be zero.
Mu + mv = 0 ⇒
v = -Mu/m = -(200)(-5.1)/(3) m/s = (200)(5.1)/3 m/s = ? m/s
Assume the two are stuck together as one body and use conservation of momentum.
M = mass of rail car = 2000 kg
u = initial speed of car = 15 m/s
m = mass of car = 500 kg
v = initial velocity of car = -24 m/s (Note the negative sign.)
w = final speed of combined mass = ?
Mu + mv = (M + m)w ⇒
w = (Mu + mv) / (M + m)
Plug in the numbers. Be careful with signs. If w is positive, it ravels east. If w is negative, it travels west. You can finish from here.