In: Computer Science
Answer question in Python, show all code:
Write a program that calculates and displays the end of year balances in a savings account if $1,000 is put in the account at 6% interest for five years. For this problem, assume interest is calculated annually. (That is, if I put $1000 in a bank account at the beginning of the year, then the balance at the end of the year is $1,000 + $1,000*6%.) You may assume no money is removed from the account over this period.
Your program output should look like this:
Balance after year 1 is $ 1060.0
Balance after year 2 is $ 1123.6
Balance after year 3 is $ 1191.02
Balance after year 4 is $ 1262.48
Balance after year 5 is $ 1338.23
Any doubts comment below.Thank you.
PYTHON CODE:
balance = 1000 # The bank balance begenning of the year.
for i in range(1,6): #loop for 5 years
balance = balance+((balance*6)/100) # calculating interest and add
it to the balance
print("Balance after year %d is $ %.2f"%(i,balance)) #printing
balance yearly