A plumber opens a savings account with 100000 at the beginni
A plumber opens a savings account with $100,000 at the beginning of January. He then makes a deposit of $1000 at the end of each month for next 12 months (starting at the end of January). Interest is calculated and added to his account at the end of each month (before the $1000 deposit is made). The monthly interest rate depends on the amount A in his account at the time interest is calculated, in the following way: A
Solution
Since now specific language choice is given, writing the solution in Python :
Code:
balance = 100000;
print \'the month, the rate, the amount of interest, new balance\';
for mno in range(12):
month = mno + 1;
#find interest rate
interestRate = 0.01;
if( balance > 110000 ):
if( balance <= 125000 ):
interestRate = 0.015
else:
interestRate = 0.02
#calculate interest
interest = balance*interestRate;
newbalance = balance + interest + 1000;
print str(month)+\', \'+ str(round(interestRate,2)) +\', \'+ str(round(interest,2))+ \\
\', \'+ str( round(newbalance,2));
balance = newbalance;
