Since the total money invested is 5000 then if the first investement was n
then the second investment will be 5000 - n.
Since the money was only invested for a year the amount earned will be invested * rate.
Using this equation we get
n * 0.07 + (5000 - n) * 0.08 = 360
Simplify to get
400 - 0.01n = 360
0.01n = 40\
n = 4000
This means that the amount invested at 7% was $4000 and at 8% $1000 was invested.