Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <title>Julian's Loan Calculator</title>
- <style>
- h1 {
- color: blue;
- }
- </style>
- </head>
- <body>
- <h1 align="middle">Loan Calculator</h1>
- <p align="center"><b>Calculate your loan repayment below</b></p>
- <hr />
- <script>
- function computeLoan()
- {
- var amount = document.getElementById('amount').value;
- var interest_rate = document.getElementById('interest_rate').value;
- var months = document.getElementById('months').value;
- var interest = (amount * (interest_rate * .01)) / months;
- var payment = ((amount / months) + interest)
- var message = "Monthly Payment = $"+payment.toLocalString();
- document.getElementById('payment').innerHTML = message;
- if(200 < 200)
- {
- document.getElementById('payment').innerHTML = 'Lower than 200';
- }
- else
- {
- document.getElementById('payment').innerHTML = 'Greater than or equal to 200'
- }
- }
- </script>
- <p>Loan Amount: $<input id="amount" type="number" min="1" max="10000000"></p>
- <p>Interest Rate: <input id="interest_rate" type="number" min="1" max="100" value="9" step=".1"></p>
- <p>Months: <input id="months" type="number" min="1" max="72" value="1" step="1"></p>
- <input type="button" value="Calculate" onclick="computeLoan()"/>
- <h2 id="payment"></h2>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement