john invested $4000 into stocks(s) and bonds(b). The stocks earned 7% interest. the bonds earned 9% interest. if the investment earned $300, how much money did john have in stocks and bonds. my question- how do I write this formula so I can find the answer

4000=S+ B

300=0.07S + 0.09B

to solve, B=4000-S or
300=0.07S + 0.09(4000-S) then solve for S

To find the amount of money John had in stocks and bonds, we need to set up a mathematical formula based on the given information. Let's assume the amount invested in stocks is x and the amount invested in bonds is y.

According to the problem, John invested a total of $4000, so we have the equation:

x + y = $4000

We are also provided with the earnings from the investments, where the stocks earned 7% interest and the bonds earned 9% interest. The total earnings from these investments is given as $300.

The earnings from stocks can be calculated by multiplying the amount invested in stocks (x) by the interest rate of 7%, or 0.07:

0.07x

Similarly, the earnings from bonds can be calculated by multiplying the amount invested in bonds (y) by the interest rate of 9%, or 0.09:

0.09y

Since the total earnings from these investments is $300, we set up another equation:

0.07x + 0.09y = $300

Now we have a system of two equations:

x + y = $4000
0.07x + 0.09y = $300

Solving this system of equations will provide the values of x and y, representing the amounts invested in stocks and bonds, respectively.