• API
• FAQ
• Tools
• Trends
• Archive
SHARE
TWEET

# Untitled

a guest Feb 24th, 2013 103 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. ## ps1, prob 3
2. print 'Given a starting balance and interest rate, this program will calculate your minimum monthly payment,'
3. print 'that will pay off your balance in 12 months or less.'
4.
5. balance = float(raw_input('Enter the outstanding balance on your credit card:'))
6. interestrate = float(raw_input('Enter the annual credit card interest rate as a decimal:'))
7.
8. lowerbound=balance/12
9. upperbound=(balance*(1+(interestrate/12))**12)/12
10. payment=(lowerbound+upperbound)/2
11.
12. def twelvemonth ():
13.     global payment
14.     global lowerbound
15.     global upperbound
16.     month = 0
17.
18.     while month <=11:
19.         month = month + 1
20.         if month==1:
21.             calcbalance = balance
22.         intowed = calcbalance*(interestrate/12)
23.         calcbalance = calcbalance + intowed - payment
24.         if -.12 <= calcbalance <= 0 and month == 12:
25.             print 'Monthly payment to pay off debt in 1 year: \$' + str(round(payment, 2))
26.             print 'Number of months needed:  ' + str(month)
27.             print 'Balance:  \$' + str(round(calcbalance, 2))
28.         if calcbalance < -.12 and month == 12:
29.             upperbound=payment
30.             payment=(payment+lowerbound)/2
31.             twelvemonth ()
32.         if calcbalance > 0 and month == 12:
33.             lowerbound=payment
34.             payment=(payment+upperbound)/2
35.             twelvemonth ()
36.
37. twelvemonth ()
RAW Paste Data
Top