Answer
The direction of the velocity of ship A relative to ship B is $~~1.5^{\circ}~~$ east of north.
Work Step by Step
We can find the components of ship A's velocity relative to the port:
$v_{Ax} = (24~knots)~cos~45^{\circ} = 17.0~knots$ (west)
$v_{Ay} = (24~knots)~sin~45^{\circ} = 17.0~knots$ (north)
We can find the components of ship B's velocity relative to the port:
$v_{Bx} = (28~knots)~sin~40^{\circ} = 18.0~knots$ (west)
$v_{By} = (28~knots)~cos~40^{\circ} = 21.4~knots$ (south)
We can find the components of the velocity of ship A relative to ship B:
$v_x = 17.0~knots - 18.0~knots = -1.0~knot~ (west) = 1.0~knot~ (east)$
$v_y = 17.0~knots+21.4~knots = 38.4~knots~(north)$
We can find the direction as an angle $\theta$ that is east of north:
$tan~\theta = \frac{1.0}{38.4}$
$\theta = tan^{-1}~\frac{1.0}{38.4}$
$\theta = 1.5^{\circ}$
The direction of the velocity of ship A relative to ship B is $~~1.5^{\circ}~~$ east of north.