Answer:
18 km/h
Step-by-step explanation:
Let S km be the distance between ports M and N, x km/h be the speed of the motorboat in still water. Then x-2 km/h is the speed of the motorboat upstream and x+2 km/h is the speed of the motor boat downstream.
1. The motorboat traveling downstream covers the distance between port M and port N in 6 hours, then

2. Once, the motorboat stopped 40 km before reaching N, turned around, and returned to M. This took the motorboat 9 hours. Then

From the first equation
Substitute it into the second equation:

Now

The speed of the motorboat cannot be less than the speed of the current, thus, x=18 km/h.