Write a function that prints a loan amortization table (principal, interest rate, and number of months) are provided via form elements. The principal amount and interest rate should be entered through a text box. However, the number of months should be entered through a drop down list containing the values 12, 24, 36, 48, and 60. A button to perform the calculation should be created, and the inputs should be grouped in a field set. When the button is pressed, a HTML
element should be updated to hold the table.
The input parameters are a loan amount (floating point), an interest rate (floating point), and a number of months for payoff (integer). The function should return a string containing an HTML table.
You will then calculate a monthly payment based on the following formula:
Where:
• M is the monthly payment
• P is the principal amount (the amount of the loan)
• r is the monthly interest rate (i.e. 1/12th of the annual interest rate)
• n is the number of payments (i.e. the number of months of the loan)
Furthermore, we can calculate how much of the monthly payment is applied to the interest, and how much is applied to the principal by the formula:
Where:
• i is the amount of interest
• P is the remaining principal amount
• r is the monthly interest rate
![1093_b.png](https://secure.tutorsglobe.com/CMSImages/1093_b.png)