''' Program allows the user to input the beginning balance and the amount to be contributed at the end of each year. Displays the amount of money at the end of each year and at the end of the 10 years using interest rate of 4% compounded annually. Inputs: begBalance = beginning balance annualAmount = annual amount to be contributed at the end of the years Constants: intRate = 4% numYears = 10 Outputs: endBalance = Balance at the end of the year Calculation Strategy: Iterate over numYears. Display endBalance for each iteration and accumulate accBalance over numYears, display accBalance at the end of the loop. ''' try: # Inputs begBalance = float(input("Enter beginning balance: ")) annualAmount = float(input("Enter amount to be contributed at the end of each year: ")) # Constants numYears = 10 intRate = 0.04 # for loop endBalance = begBalance # Calculations print("{0:8}{1:12}".format("Year", "Ending Balance")) for year in range(1, numYears+1): endBalance = endBalance * (1+intRate) + annualAmount print("{0:<10}{1:^12.2f}".format(year, endBalance)) print("Balance at the end of 10 years: {0:8.2f}".format(endBalance)) except: print("Invalid entries, enter numeric values only")