Explanation:
If a point on a line is the midpoint, that means that the two segments created by the point are equal. In this case, XA = AY
We can set the two lengths equal to each-other.

Now that we know x = 6, we can solve for the lengths of each segment.
XA = 3x = 3(6) = 18
AY = 5x - 12 = 5(6) - 12 = 30 -12 = 18
XY = 3x + 5x - 12 = 8x - 12 = 8(6) - 12 = 48 - 12 = 36