as I read it, what I get is that
x = returned profits or yielded interest from investment in A
y = returned profits or yielded interest from investment in B
T = total amount invested or namely A + B.
4000 were invested in A, and it yielded 5%, what's 5% of 4000? (5/100)(4000) = 200 = x.
we know the total amount is T, since A get 4000, B must have gotten T - 4000, or the slack. We also know that B yielded a 2% profit, well, what's 2% of T - 4000? (2/100)(T-4000) = y.
we also know that, whatever "x" and "y" are, their sum total yielded a 4% returns from T, or the total principal, what's 4% of T? (4/100)T = 0.04T.