create a html named mortgagePaymentTable.html that lets an user enter the loan a
ID: 673957 • Letter: C
Question
create a html named mortgagePaymentTable.html that lets an user enter the loan amount, loan period in number of years, the beginning interest rate and ending interest rate, then display the monlthy and total payments for each interest rate starting from the beginning interest rate to the end interest rate, with an increment of 1/8
1) please use the following formula to compute the monthly payment:
2) for total payment, you should calculate it as:
totalpayment = monthlyPayment * numofYears * 12
3) The beginning rate is a dropdown list with the selection of 1%, 2%, 3%, 4%, and 5%
4) The ending rate is a dropdown list with the selection of 6%, 7%, 8%, 9%, and 10%.
Explanation / Answer
Answer :
mortgagePaymentTable.html
<head><title>Mortagage Payment Table</title></head>
<body bgcolor="cyan">
<form name="loan">
<table>
<tr><td colspan="3"><b>Enter Your Loan Information:</b></td></tr>
<tr>
<td>1)</td>
<td>Enter The Loan Amount:</td>
<td><input type="text" name="principal" size="12"
></td>
</tr>
<tr>
<td>2)</td>
<td>Enter Given Rate of Interest 1/8 i.e 0.125 or Any :</td>
<td><input type="text" name="interest" size="12"
></td>
</tr>
<tr>
<td>3)</td>
<td>Enter The Loan Period in Number of Years:</td>
<td><input type="text" name="years" size="12"
></td>
</tr>
<tr><td colspan="3">
<input type="button" value="Compute">
</td></tr>
<tr><td colspan="3">
<b>Your Payment Information of Loan:</b>
</td></tr>
<tr>
<td>4)</td>
<td>Your Monthly Payment Will Be:</td>
<td><input type="text" name="payment" size="12"></td>
</tr>
<tr>
<td>5)</td>
<td>Your Total Payment Will Be:</td>
<td><input type="text" name="total" size="12"></td>
</tr>
<tr>
<td>6)</td>
<td>Your Total Interest Payments Will Be:</td>
<td><input type="text" name="totalinterest" size="12"></td>
</tr>
</table>
</form>
<script language="JavaScript">
function calculate()
{
var principal = document.loan.principal.value;
var interest = document.loan.interest.value / 100 / 12;
var payments = document.loan.years.value * 12;
var x = Math.pow(1 + interest, payments);
var month = (principal*x*interest)/(x-1);
if (!isNaN(month) &&
(month != Number.POSITIVE_INFINITY) &&
(month != Number.NEGATIVE_INFINITY)) {
document.loan.payment.value = round(month);
document.loan.total.value = round(month * payments);
document.loan.totalinterest.value =
round((month * payments) - principal);
}
else {
document.loan.payment.value = "";
document.loan.total.value = "";
document.loan.totalinterest.value = "";
}
}
function round(x) {
return Math.round(x*100)/100;
}
</script>
</body>
</html>
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.