Write an algorithm to settle the following question:
A bank account starts out with $10,000. Interest is compounded monthly at 6 percent per year (0.5 percent per month). Every month, $500 is withdrawn to meet college expenses. After how many years is the account depleted?

Here is what I got so far. Can you tell if I am on the right track.

Step 1 Start with the table:
Month Balance
0 $10,000.00


Step 2 Repeat steps 2a, 2b, 2c while the balance is greater than $0.00
Step 2a. Add a new row to the table.
Step 2b. In column 1 of the new row, labeled "Month", put one more than the preceding month value.
Step 2c. In column 2 of the new row, labeled "Balance", place the value of this formula
b * (1 + 0.005) - 500
where b is the preceding balance value.


Step 3 Read the last number in the month column (let's call it months). Report that the account will be depleted in (months / 12) years and (months % 12) months.

Respuesta :

Answer:

algorithm

original = float(raw_input("Enter initial balance: "))

interest = float(raw_input("Enter promised return: "))

expenses = float(raw_input("Enter monthly expenses: "))

interest = interest / 100 / 12

month = 0

balance = original

if balance * interest - expenses >= 0:

print "You don't need to worry."

else:

while balance + balance * interest - expenses >= 0: # negation of the if condition

balance = balance + interest * balance # in one month

balance = balance - expenses

month = month + 1

print month, balance

print month / 12, "years and", month % 12, "months"

ACCESS MORE
ACCESS MORE
ACCESS MORE
ACCESS MORE