Advertisement
Guest User

Untitled

a guest
Nov 21st, 2019
623
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.08 KB | None | 0 0
  1. The TidBit Computer Store (Chapter 3, Project 10) has a credit plan for computer purchases. Inputs are the annual interest rate and the purchase price. Monthly payments are 5% of the listed purchase price, minus the down payment, which must be 10% of the purchase price.
  2. Write a GUI-based program that displays labeled fields for the inputs and a text area for the output. The program should display a table, with appropriate headers, of a payment schedule for the lifetime of the loan. Each row of the table should contain the following items:
  3.  
  4. The month number (beginning with 1)
  5. The current total balance owed
  6. The interest owed for that month
  7. The amount of principal owed for that month
  8. The payment for that month
  9. The balance remaining after payment
  10. The amount of interest for a month is equal to balance * rate / 12. The amount of principal for a month is equal to the monthly payment minus the interest owed. Your program should include separate classes for the model and the view. The model should include a method that expects the two inputs as arguments and returns a formatted string for output by the GUI.
  11. """
  12. Program: tidbit.py
  13. Project 3.10
  14.  
  15. Print a payment schedule for a loan to purchase a computer.
  16.  
  17. Input
  18. purchase price
  19.  
  20. Constants
  21. annual interest rate = 12%
  22. downpayment = 10% of purchase price
  23. monthly payment = 5% of purchase price
  24.  
  25. """
  26.  
  27. ANNUAL_RATE = .12
  28. MONTHLY_RATE = ANNUAL_RATE / 12
  29.  
  30.  
  31. purchasePrice = float(input("Enter the puchase price: "))
  32.  
  33. monthlyPayment = .05 * (purchasePrice - (.10 * purchasePrice))
  34. month = 1
  35. balance = purchasePrice
  36. print("Month Starting Balance Interest to Pay Principal to Pay Payment Ending Balance")
  37. while balance > 0:
  38. if monthlyPayment > balance:
  39. monthlyPayment = balance
  40. interest = 0
  41. else:
  42. interest = balance * MONTHLY_RATE
  43. principal = monthlyPayment - interest
  44. remaining = balance - monthlyPayment
  45. print("%2d%15.2f%15.2f%17.2f%17.2f%17.2f" % \
  46. (month, balance, interest, principal, monthlyPayment, remaining))
  47. balance = remaining
  48. month += 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement