Notice that Fred can always invest in 1-year deposits and get this money at the beginning of the next year for further investments. This means that all available money will always be invested and we do not bother about the rest.
Year 1: invest $ x_1 $ in 1-year deposit $ 4\% $, $ x_2 $ in 2-year $ 9\% $
- $ x_1 + x_2 \leq 5000 $ (= available money)
Year 2: invest $ x_3 $ in 1-year $ 4\% $, $ x_4 $ in 2-year $ 9\% $, $ x_5 $ in 3-year $ 15\% $
- $ x_3 + x_4 + x_5 \leq 1.04 \times x_1 $ (= available money)
Year 3: invest $ x_6 $ in 1-year $ 4\% $, $ x_7 $ in 2-year $ 9\% $, $ x_8 $ in 3-year $ 15\% $
- $ x_6 + x_7 + x_8 \leq 1.04 \times x_3 + 1.09 \times x_2 $ (= available money)
Year 4: invest $ x_9 $ in 1-year $ 4\% $, $ x_{10} $ in 2-year $ 9\% $
- $ x_9 + x_{10} \leq 1.04 \times x_6 + 1.09 \times x_4 $ (= available money)
Year 5: invest $ x_{11} $ in 1-year $ 4\% $
- $ x_{11} \leq 1.04 \times x_9 + 1.09 \times x_7 + 1.15 \times x_5 $ (= available money)
Year 6:
- available money = $ 1.04 \times x_{11} + 1.09 \times x_{10} + 1.15 \times x_8 $ = final cash = maximize !
So, if I did not make a mistake, there are 11 unknowns x1, ..., x11
for the individual investments, 5 linear inequalities (1) - (5), and one linear goal function (6) to be maximized. This linear programming problem can be solved by the simplex algorithm.
ADDED (based on Mike's comment): for completeness the 11 inequalities xi >= 0
for the unknowns should be added.