Points will be taken off if your code is not adequately commented.
For an account that accrues compound interest, the formula for the balance after one interest period is
Balancenew = (Balancestarting + Deposits - Withdrawls) * (1+I)
where Balance is the initial or new amount of money in the account, Deposits are any money added to the account, Withdrawals are any money removed from the account, and I is the interest rate (given as a decimal - i.e., 2% interest is entered in the equation as 0.02).
Repeating this formula for each interest compounding period will reflect the (hopefully growing) change in balance over time.
Problem 1. Write a function that accepts the starting balance, deposits, withdrawals, and interest rate as inputs and then returns the resulting balance. Name the function compounded_interest.
Problem 2. Use your compounded_interest function to calculate how many years it will take to reach a balance of $100,000 from an initial balance of $10,000, an annual deposit of $2,000, and an interest rate of 2.5% (0.025).
Problem 3. Use your function to calculate the same scenario as Problem 2, but with an annual withdrawal of $500.
Problem 4. Using your function, determine the balance in an account with $100 initial balance, $50 per month deposit, $20 per month withdrawal, and 0.15% interest compounded monthly (0.0015), after a total of 20 years (12 months per year).
Problem 5. Assume a savings account of $1,000 starting balance, $250 per month deposit, an interest rate of 3%, and a one-time withdrawal after 24 months of $2,000. What is the balance after a total of 60 months?