Let x represent the amount invested at 7%.
Then 9000-x is the amount invested at 4%
total interest earned is:
0.07x + 0.04(9000-x) = 510
0.07x + 360 - 0.04x = 510
0.03x = 150
x = 5000 the amount invested at 7%
9000 - 5000 = 4000 the amount invested at 4%