Created
March 25, 2012 01:35
-
-
Save Katharine/2190642 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
balance = float(raw_input("Enter the outstanding amount on your credit card: ")) | |
interest_rate = float(raw_input("Enter the annual credit card interest rate as a decimal: ")) | |
payment_rate = float(raw_input("Enter the minimum monthly payment rate as a decimal: ")) | |
total_payment = 0 | |
for month in xrange(1, 13): # (xrange? like range, but usually better.) | |
payment = round(payment_rate * balance, 2) | |
interest_paid = round((interest_rate / 12.0) * balance, 2) | |
principal_paid = payment - interest_paid | |
balance = balance - principal_paid | |
total_payment += payment | |
print "Month: %s" % month | |
print "Minimum monthly payment: $%s" % payment | |
print "Principal paid: $%s" % principal_paid | |
print "Remaining balance: $%s" % balance | |
print "RESULT" | |
print "Total amount paid: $%s" % total_payment | |
print "Remaining balance: $%s" % balance |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment