Pure Programmer
Blue Matrix


Cluster Map

Project: Amortization Table

Write a program that computes and prints a loan amortization table for a [[Fixed-Rate Loan]]. The amount of the loan, interest rate per annum and the term in years should be supplied on the command line. Your table should have columns for payment month (0 - term * 12), payment amount, principle amount of payment, interest amount of payment, balance after payment. Use the tab character to separate columns. While the column headers and the data man not align when displayed on the string, using tab-delimited columns will make the output of the program easier for other programs to use.

The table should assume a payment is due for each month. This means that the interest rate per month is 1/12th the value entered on the command line. The interest rate should be entered as a decimal value so for example 5% would be entered as 0.05. In addition, the number of terms in months will be 12 times the term in years entered on the command line.

Using floating point variables we will accumulate some small error that causes us to not get to exactly zero balance. If you format the balance to show 16 decimal places you will see this error accumulating. This phenomenom is called accumulation error and is to be expected when working with floating point data.

Output
$ python3 AmortizationTable1.py 10000 0.05 2 Month Payment Principle Interest Balance 0 10000.00 1 438.71 397.05 41.67 9602.95 2 438.71 398.70 40.01 9204.25 3 438.71 400.36 38.35 8803.89 4 438.71 402.03 36.68 8401.86 5 438.71 403.71 35.01 7998.15 6 438.71 405.39 33.33 7592.76 7 438.71 407.08 31.64 7185.69 8 438.71 408.77 29.94 6776.91 9 438.71 410.48 28.24 6366.44 10 438.71 412.19 26.53 5954.25 11 438.71 413.90 24.81 5540.34 12 438.71 415.63 23.08 5124.71 13 438.71 417.36 21.35 4707.35 14 438.71 419.10 19.61 4288.25 15 438.71 420.85 17.87 3867.41 16 438.71 422.60 16.11 3444.81 17 438.71 424.36 14.35 3020.45 18 438.71 426.13 12.59 2594.32 19 438.71 427.90 10.81 2166.41 20 438.71 429.69 9.03 1736.73 21 438.71 431.48 7.24 1305.25 22 438.71 433.28 5.44 871.97 23 438.71 435.08 3.63 436.89 24 438.71 436.89 1.82 -0.00

Solution