35.3k views
1 vote
(Financial application: compound value) Suppose you save $100 each month into a savings account with the annual interest rate 5%. Thus, the monthly interest rate is 0.05/12 = 0.00417. After the first month, the value in the account becomes 100 * (1 + 0.00417) = 100.417 After the second month, the value in the account becomes (100 + 100.417) * (1 + 0.00417) = 201.252 After the third month, the value in the account becomes (100 + 201.252) * (1 + 0.00417) = 302.507 and so on. Write a program that prompts the user to enter a monthly saving amount and displays the account value after the sixth month. (In Exercise 5.30, you will use a loop to simplify the code and display the account value for any month.)

1 Answer

2 votes

Answer:

Follow the code or function below...

Do not forget the saving amount, and initialise the balance with that amount. Inside the loop, work out and add the interest and then add the saving amount for the next month.

Step-by-step explanation:

inicial = float(eval(input('Enter the montly saving amount: ')))

x = (1 + 0.00417)

month_one = inicial * x

month_two = (inicial + month_one) * x

month_three = (inicial + month_two) * x

month_four = (inicial + month_three) * x

month_five = (inicial + month_four) * x

month_six = (inicial + month_five) * x

print('The sixth month value is: '+str(month_six))

Don't forget the saving amount, and initialise the balance with that amount. Inside the loop, work out and add the interest and then add the saving amount for the next month.

balance = 801

for month in range(6):

balance = balance * (1.00417)

print(balance)

User Wjbeau
by
6.1k points