Advertisement
Guest User

Untitled

a guest
Aug 24th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>Julian's Loan Calculator</title>
  5. <style>
  6. h1 {
  7. color: blue;
  8. }
  9. </style>
  10. </head>
  11. <body>
  12. <h1 align="middle">Loan Calculator</h1>
  13. <p align="center"><b>Calculate your loan repayment below</b></p>
  14. <hr />
  15.  
  16. <script>
  17. function computeLoan()
  18. {
  19. var amount = document.getElementById('amount').value;
  20. var interest_rate = document.getElementById('interest_rate').value;
  21. var months = document.getElementById('months').value;
  22. var interest = (amount * (interest_rate * .01)) / months;
  23. var payment = ((amount / months) + interest)
  24. var message = "Monthly Payment = $"+payment.toLocalString();
  25. document.getElementById('payment').innerHTML = message;
  26. if(200 < 200)
  27. {
  28. document.getElementById('payment').innerHTML = 'Lower than 200';
  29. }
  30. else
  31. {
  32. document.getElementById('payment').innerHTML = 'Greater than or equal to 200'
  33. }
  34. }
  35. </script>
  36. <p>Loan Amount: $<input id="amount" type="number" min="1" max="10000000"></p>
  37. <p>Interest Rate: <input id="interest_rate" type="number" min="1" max="100" value="9" step=".1"></p>
  38. <p>Months: <input id="months" type="number" min="1" max="72" value="1" step="1"></p>
  39. <input type="button" value="Calculate" onclick="computeLoan()"/>
  40. <h2 id="payment"></h2>
  41.  
  42.  
  43.  
  44.  
  45. </body>
  46. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement