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.
The following variables contain values as described below:
balancethe outstanding balance on the credit card;
annualannual interest rate as a decimal;
monthlyminimum monthly payment rate as a decimal.
For each month, calculate statements on the monthly payment and remaining balance, and print to screen.
Finally, print out the total amount paid that year and the remaining balance at the end of the year.
Solution:
The minimum interest of each month is $$\text{minipay}=\text{balance}\times\text{monly}$$ and the new balance is $$(\text{balance}-\text{minipay})\times(1+\frac{\text{annual}}{12})$$ The balance should be updated each month.
Python code
The result shows that the monthly total pay is 1775.55 yet the remaining balance is still 3147.67, which means paying the minimum is definitely not a good idea!
没有评论:
发表评论