Jump to content
  • Advertisement
Sign in to follow this  
musafir2007

Please check my math..

This topic is 3722 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

A deposit of $50 is made the 1st day of each month in a savings account that pays 12% compounded monthly. What is the balance at the end of two years?




monthly_deposit = 50
interest_rate = .12
term_length = 24 #number of months
acct_balance = 50

print "Initial Balance: ", acct_balance
print "Monthy Deposit: ", monthly_deposit
print "Month Compounded Interest Rate: ", interest_rate*100, "%"
print "Length of Term: ", term_length, " Months"

for i in range (term_length-1): #runs the loop term_length times
    acct_balance = acct_balance+(acct_balance*interest_rate)+monthly_deposit

print "\nBalance at end of ", term_length, " month term: ", "$", acct_balance

raw_input()




MY OUTPUT: http://img242.imageshack.us/img242/8608/61308974ze5.jpg Thanks! [Edited by - musafir2007 on July 17, 2008 11:44:35 PM]

Share this post


Link to post
Share on other sites
Advertisement
for i in range (term_length-1): #runs the loop term_length times
acct_balance = acct_balance+(acct_balance*interest_rate)+monthly_deposit

Considering the $50 is paid in on the first day of the month, and the interest is paid at the end of the month. Wouldn't you want to increase the account balance by the monthly deposit and then work out the interest?

begin loop for each month
add the monthly deposit to the account balance
increase the account balance using the interest rate
end loop

EDIT: Just noticed, your initializing the account balance to $50 so my loop would be wrong, but if you was to start with an empty account then you would need to add the monthly ammount to the balance and then add interest to the new total.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!