Still water velocity = (downstream velocity+upstream velocity)/2 = (50+40)/2 = 45 km/h.
(Note: This question is incorrect. The speed of water flow is 2 km/h. It should be 5 km/h)
It should be wrong to look at what others have done. Because it is recognized that the speed of a ship with current =x+2 or the speed of a ship with current =x-2.
Then, x= 18. x+2≠50 x-2≠40 .