For simple interest:
Interest = Principle*Rate*Time
Let x be the amount of the principle that John invests at 3% (0.03). The interest he earns at 3% is:
Interest at 3% = x*(0.03)*(1 year) = (0.03)x
Since his total investment is $5000, the amount John invests at 4% (0.04) is $5000-x. The interest at 4% is:
Interest at 4% = ($5000-x)*(0.04)*(1 year) = $200 - (0.4)x
The total interest earned is:
Total Interest = Interest at 3% + Interest at 4%
$176 = (0.03)x + $200 - (0.04)x
-$24 = -(0.01)x
$2400 = x
John invests $2400 at 3% and $5000 - $2400 = $2600 at 4%.