In: Computer Science
Read chapter 3 from our text, Murach's Python Programming,
focusing on coding the iteration structure (while statement). Then
code Python statements for the pseudocode under a "Payment
Schedule" shown below.
Save these Python statements in a text file named with your first
name, last name, the digits 06, and extension .py (e.g.
joelMurach06.py). To maximize points earned, first test this file
with Python IDLE to ensure it is error free, then attach the python
file to an email sent to [email protected].
Include our class code (csci233) and your leomail name in the
"Subject" line of your email to [email protected] .
Payment Schedule (example output)
month payment interest applied balance
1 50.00 2.00 48.00 352.00
2 50.00 1.76 48.24 303.76
3 50.00 1.52 48.48 255.28
...
8 50.00 0.29 49.71 9.21
9
9.26 0.05
9.21 0.00
Total 409.26
9.26 400.00
Pseudocode for a "Payment Schedule":
0. Code a comment that includes your first and last names and
leomail address.
1. Have input/prompts to enter values for:
a purchase amount, a fixed monthly payment amount, and an annual
interest rate. Example: a notepad purchase that is to cost $400.00,
with $50 monthly payments, an annual interest rate of 6 percent(a
whole number to be converted to decimal fraction) to be compounded
monthly on the remaining principal balance.
2. Assign purchase amount to the beginning balance;
3. To represent a monthly interest rate in decimal terms, multiply
the annual rate by 0.01 then divide by 12 (the months in a
year);
4. while balance is greater than zero:
a. compute the monthly interest charge on
the balance;
b. accumulate the interest charge for a
final total on interest;
c. reduce the balance due by the monthly
payment minus the interest charge (or to zero if the regular
monthly payment would exceed the outstanding balance);
d. print the month number, payment, current
month's interest charge, net amount applied to the balance, and the
remaining balance after applying the payment (net after subtracting
the interest).
5. Write a summary line with totals for the payment, interest and
applied columns.
*Note that the last payment amount is likely to be
different than the usual monthly payment.
(25 points for homework 6).
Short Summary:
**************Please upvote the answer and appreciate our time.************
Source Code:
purchaseAmount = float(input("Enter purchase amount: "))
monthlyPayment = float(input("Enter fixed monthly payment amount:
"))
APR = float(input("Enter annual interest rate: "))
#2. Assign purchase amount to the beginning balance;
beginingBalance = purchaseAmount
#3. To represent a monthly interest rate in decimal terms,
multiply the annual rate by 0.01 then divide by 12 (the months in a
year);
monthlyRate = (APR * 0.01) /12
totalInterest = 0
totalPayment = 0
month = 0
print("{0:<10} {1:<10} {2:<10} {3:<10} {4:<10}".format("Month", "Payment", "Interest", "Applied", "Balance"))
#4. while balance is greater than zero:
while beginingBalance > 0:
month += 1
# a. compute the monthly interest charge on the balance;
monthlyInterest = beginingBalance * monthlyRate
#b. accumulate the interest charge for a final total on
interest;
totalInterest += monthlyInterest
#c. reduce the balance due by the monthly payment minus the
interest charge
#(or to zero if the regular monthly payment would exceed the
outstanding balance);
if monthlyPayment > beginingBalance:
monthlyPayment = beginingBalance + monthlyInterest
beginingBalance = beginingBalance - (monthlyPayment -
monthlyInterest)
totalPayment += monthlyPayment
# d. print the month number, payment, current month's interest
charge,
#net amount applied to the balance, and the remaining balance after
applying the payment (net after subtracting the interest).
print("{0:<10} {1:<10.2f} {2:<10.2f} {3:<10.2f}
{4:<10.2f}".format(month, monthlyPayment, monthlyInterest,
monthlyPayment-monthlyInterest, beginingBalance))
#5. Write a summary line with totals for the payment, interest
and applied columns.
print("{0:<10} {1:<10.2f} {2:<10.2f}
{3:<10.2f}".format("Total", totalPayment, totalInterest,
totalPayment-totalInterest))
Refer the following screenshots for code indentation:
Sample Run:
**************************************************************************************
Feel free to rate the answer and comment your questions, if you have any.
Please upvote the answer and appreciate our time.
Happy Studying!!!
**************************************************************************************