Paying Off Credit Card Debt
Each month, a credit card statement will come with the option for you to pay a minimum amount of your charge, usually 2% of the balance due. However, the credit card company earns money by charging interest on the balance that you don't pay. So even if you pay credit card payments on time, interest is still accruing on the outstanding balance.
Say you've made a N5,000 purchase on a credit card with 18% annual interest rate and 2% minimum monthly payment rate. After a year, how much is the remaining balance? Use the following equations.
Minimum monthly payment
= Minimum monthly payment rate x Balance
(Minimum monthly payment gets split into interest paid and principal paid)
Interest Paid = Annual interest rate / 12 months x Balance
Principal paid = Minimum monthly payment - Interest paid
Remaining balance = Balance - Principal paid
For month 1, compute the minimum monthly payment by taking 2% of the balance.
Minimum monthly payment
= .02 x N5000 = N100
We can't simply deduct this from the balance because there is compounding interest. Of this N100 monthly payment, compute how much will go to paying off interest and how much will go to paying off the principal. Remember that it's the annual interest rate that is given, so we need to divide it by 12 to get the monthly interest rate.
Interest paid = .18/12 x N5000 = N75
Principal paid = N100 - N75 = N25
The remaining balance at the end of the first month will be the principal paid this month subtracted from the balance at the start of the month.
Remaining balance = N5000 - N25 = N4975
For month 2, we repeat the same steps.
Minimum monthly payment
= .02 x N4975 = N99.50
Interest Paid = .18/12 x $4975 = $74.63
Principal Paid = N99.50 - N74.63 = N24.87
Remaining Balance = N4975 - N24.87 = N4950.13
After 12 months, the total amount paid is N1167.55, leaving an outstanding balance of N4708.10. Pretty depressing!
Problem 1: Paying the Minimum
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.
Take as input:
the outstanding balance on the credit card
annual interest rate as a decimal
minimum monthly payment rate as a decimal
For each month, print out statements on the monthly payment and remaining balance in the format shown in the test cases below. Finally, print the result, which should include the total amount paid that year and the remaining balance.
Test Case 1
Enter the outstanding balance on your credit card: 4800
Enter the annual credit card interest rate as a decimal: .2
Enter the minimum monthly payment rate as a decimal: .02
Month: 1
Minimum monthly payment: 96.0
Remaining balance: 4784.0
Month: 2
Minimum monthly payment: 95.68
Remaining balance: 4768.05
Month: 3
Minimum monthly payment: 95.36
Remaining balance: 4752.16
Month: 4
Minimum monthly payment: 95.04
Remaining balance: 4736.32
Month: 5
Minimum monthly payment: 94.73
Remaining balance: 4720.53
Month: 6
Minimum monthly payment: 94.41
Remaining balance: 4704.8
Month: 7
Minimum monthly payment: 94.1
Remaining balance: 4689.11
Month: 8
Minimum monthly payment: 93.78
Remaining balance: 4673.48
Month: 9
Minimum monthly payment: 93.47
Remaining balance: 4657.9
Month: 10
Minimum monthly payment: 93.16
Remaining balance: 4642.37
Month: 11
Minimum monthly payment: 92.85
Remaining balance: 4626.89
Month: 12
Minimum monthly payment: 92.54
Remaining balance: 4611.46
RESULT
Total amount paid: 1131.12
Remaining balance: 4611.46Test Case 2
In recent years, many credit card corporations tightened restrictions by raising their minimum monthly payment rate to 4%. As illustrated in the second test case below, people will be able to pay less interest over the years and get out of debt faster.
Enter the outstanding balance on your credit card: 4800
Enter the annual credit card interest rate as a decimal: .2
Enter the minimum monthly payment rate as a decimal: .04
Month: 1
Minimum monthly payment: 192.0
Remaining balance: 4688.0
Month: 2
Minimum monthly payment: 187.52
Remaining balance: 4578.61
Month: 3
Minimum monthly payment: 183.14
Remaining balance: 4471.78
Month: 4
Minimum monthly payment: 178.87
Remaining balance: 4367.44
Month: 5
Minimum monthly payment: 174.7
Remaining balance: 4265.53
Month: 6
Minimum monthly payment: 170.62
Remaining balance: 4166.0
Month: 7
Minimum monthly payment: 166.64
Remaining balance: 4068.79
Month: 8
Minimum monthly payment: 162.75
Remaining balance: 3973.85
Month: 9
Minimum monthly payment: 158.95
Remaining balance: 3881.13
Month: 10
Minimum monthly payment: 155.25
Remaining balance: 3790.57
Month: 11
Minimum monthly payment: 151.62
Remaining balance: 3702.13
Month: 12
Minimum monthly payment: 148.09
Remaining balance: 3615.74
RESULT
Total amount paid: 2030.15
Remaining balance: 3615.74
Hints
To help you get started, here is a rough outline of the stages you should probably follow in writing your code:
Retrieve user input.
Initialize some state variables. Remember to find the monthly interest rate from the annual interest rate taken in as input.
For each month:
oCompute the new balance. This requires computing the minimum monthly payment and figuring out how much will be paid to interest and how much will be paid to the principal.
oUpdate the outstanding balance according to how much principal was paid off.
oOutput the minimum monthly payment and the remaining balance.
oKeep track of the total amount of paid over all the past months so far.
Print out the result statement with the total amount paid and the remaining balance.
Use these ideas to guide the creation of your code.