Hey guys, just working on the Problem set 1 problems, and I've got every part working, except for 1. I've got it to calculate the Monthly payments, principal Paids, and remaining balance all properly. The only thing is, that when I call my variable for remaining balance to print it out the last time, it is of by precisely $84.36 Ill post the code in the comments. All help appreciated!
#outstanding balance x = float(raw_input("Enter remaining balance on the credit card: ")) #annual interest rate y = float(raw_input("Enter annual interest rate as a decimal: ")) #minimum monthly payment rate z = float(raw_input("Enter the minimum monthly payment rate as a decimal: ")) #minimum monthly payment a = float( z * x ) #interest paid b = float( y / 12 * x) #principal paid c = ( a - b) #remaining balance d =( x - c ) #Total ammount paid f = 0 for i in range (1, 13): s = str(i) print "Month: ", s print "Minimum monthly payment: $", round(a, 2) print "Principal Paid: $", round(c, 2) print "Remaining Balance: $", round(d, 2) f += float(a) a = float(z * d) b = float(y / 12 * d) c = float(a - b) d = float(d - c) print "\n" print "RESULT: " print "Total ammount paid: $", round(f, 2) print "Remaining Balance: $", round(d, 2)
Ok, so I figured out the problem, but I don't know how to fix it. The problem is that its subtracting another Principal payment from the remaining balance, before printing the result. If anyone knows how to fix this, I'd be grateful
Ok guys, sorry to bother you. I figured out what the problem was, and made the appropriate changes. I was calculating the remaining balance incorrectly. Just for reference, ill post the code in the comments, before closing it. Thanks guys =)
#outstanding balance x = float(raw_input("Enter remaining balance on the credit card: ")) #annual interest rate y = float(raw_input("Enter annual interest rate as a decimal: ")) #minimum monthly payment rate z = float(raw_input("Enter the minimum monthly payment rate as a decimal: ")) #Total ammount paid f = 0 for i in range (1, 13): s = str(i) #minimum monthly payment a = float( z * x ) #interest paid b = float( y / 12 * x) #principal paid c = ( a - b) #remaining balance x -= (c) f += float(a) print "Month: ", s print "Minimum monthly payment: $", round(a, 2) print "Principal Paid: $", round(c, 2) print "Remaining Balance: $", round(x, 2) print "\n" print "RESULT: " print "Total ammount paid: $", round(f, 2) print "Remaining Balance: $", round(x, 2)
Join our real-time social learning platform and learn together with your friends!