Ask your own question, for FREE!
MIT 6.00 Intro Computer Science (OCW) 15 Online
OpenStudy (anonymous):

I was wondering if anyone could help me figure out why my program isn't compounding. for month in range(1,13): print 'Month: ' , str(month) print 'Minimum monthly payment: ' , str(float(mmpr) * float(ob)) mmp = float(str(float(mmpr) * float(ob))) print 'Interest payed: $' , str(float(air)/12 * float(ob)) ip = float(str(float(air)/12 * float(ob))) print 'Principal payed: $' , str(float(mmp) - float(ip)) pp = float(str(float(mmp) - float(ip))) print 'Ramaning balance: $' , str(float(ob) - float(pp)) rb = float(str(float(ob) - float(pp)))

OpenStudy (anonymous):

In third line where you wrote: print 'Minimum monthly payment: ' , str(float(mmpr) * float(ob)) mmpr is not defined (varable should be define before use

OpenStudy (anonymous):

I ran out of chars the opening of the program reads: ##ob stands for outstand balance on the credit card ob = float(raw_input('What is the outstanding balance on the credit card?')) ##air stands for anual interest rate air = float(raw_input('What is the anual interest rate as a decimal?')) ##mmpr stands for minimum monthly payment rate mmpr = float(raw_input('What is the minimum monthly payment rate as a decimal?') I don't have a problem with anything coming up with an error, but when I run the program it doesn't compound. This is the print out I get the screen that I attached. As you can see every month it prints the same information rather than compounding the money. I would greatly appreciate any help on this issue. Thanks so much!

OpenStudy (anonymous):

I guess I should attach a prt scr of my program too.

OpenStudy (anonymous):

copy python script codes at http://dpaste.com/ paste it then copy the address produced and paste it at your question

OpenStudy (anonymous):

This is my code for minimum monthly payment problem. Try to figure out how it's working. http://dpaste.com/784718/ In the loop you always do same calculations with same data, instead of this you shuld do same calculations with diferent (updatet with each loop cycle) data.

OpenStudy (anonymous):

Sorry for the first stupid answer :) The reason it is not working is that remaining balance should be the new outstanding balance so change the line : rb = float(str(float(ob) - float(pp))) to ob = float(str(float(ob) - float(pp))) then It start to work although the calculation needs to be checked also worth to use less code as below: for month in range(1,13): print 'Month: ' , str(month) mmp = float(str(float(mmpr) * float(ob))) print 'Minimum monthly payment: ' , str(mmp) ip = float(str(float(air)/12 * float(ob))) print 'Interest to be paied: $' , str(ip) pp = float(str(float(mmp) - float(ip))) print 'Principal paied: $' , str(pp) ob = float(str(float(ob) - float(pp))) print 'Ramaning balance: $' , str(ob)

OpenStudy (anonymous):

http://dpaste.com/hold/784997/

OpenStudy (anonymous):

Thank you so much Shahrouz!! I greatly appreciate your help. Thanks to everyone else that helped me as welll! <3

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!