#Write a program to calculate the credit card balance after one year if a person only pays the minimum monthly payment #required by the credit card company each month. Keep it to two decimals. #output should be: #Month: 1 #Minimum monthly payment: 96.0 #Remaining balance: 4784.0 #Final line: #Total paid: 96.0 #Remaining balance: 4784.0 ######################################################## Do Not Copy################################### balance = 5000.00 annualInterestRate = 0.12 monthlyPaymentRate = 0.01 ######################################################## Do Not Copy################################### month = 1 totalPaid = 0 while month <= 12: #Monthly interest rate= (Annual interest rate) / 12.0 monthlyIntRate = annualInterestRate/12.0 #Minimum monthly payment = (Minimum monthly payment rate) x (Previous balance) minMonthlyPayment = monthlyPaymentRate*balance #Monthly unpaid balance = (Previous balance) - (Minimum monthly payment) balance -= minMonthlyPayment #Updated balance each month = (Monthly unpaid balance) + (Monthly interest rate x Monthly unpaid balance) balance += (monthlyIntRate*unpaidBalance) print ('Month: ' + str(month)) print ('Minimum monthly payment: ' + str(minMonthlyPayment)) print ('Remaining balance: ' + str(balance)) totalPaid += minMonthlyPayment month += 1 print ('Total Paid: ' + str(totalPaid)) print ('Remaining balance: ' + str(balance))
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question