-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathpset2prob2.py
More file actions
22 lines (18 loc) · 801 Bytes
/
pset2prob2.py
File metadata and controls
22 lines (18 loc) · 801 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
'''
This program calculates and prints out the minimum fixed monthly payment needed
to pay off the total credit card balance within 12 months. It starts by
checking whether a minimum amount of $10 is sufficient, and iterates over
and over by increasing the amount by $10 until the whole debt is payed.
'''
balance = 4772
annualInterestRate = 0.2
monthlyInterestRate = annualInterestRate/12
minMonthlyPayment = 10
newBalance = balance
while newBalance > 0: #Loop checks whether debt is still unpayed
newBalance = balance
for month in range (1,13): #Calculates yearly payment
newBalance = (newBalance - minMonthlyPayment) * (1 + monthlyInterestRate)
if newBalance > 0:
minMonthlyPayment = minMonthlyPayment + 10 #Increase payment by $10
print ("Lowest payment: " + str(minMonthlyPayment))