months = years * 12 total_amount = initial_amount for month in range(1, months + 1): total_amount += monthly_contribution total_amount *= (1 + (annual_interest_rate / 100) / 12) initial_amount = float(input("Enter the initial amount saved: ")) monthly_contribution = float(input("Enter the monthly contribution: ")) annual_interest_rate = float(input("Enter the annual interest rate (in %): ")) years = int(input("Enter the number of years: ")) print(f"Total savings after {years} years: ${total_savings:.2f}")