A simple interest calculator in JavaScript I wrote a long time ago while teaching JavaScript programming in one of the colleges here in the Philippines.

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me at the following email address for further details.  If you want to advertise on my website, kindly contact me also at my email address also. Thank you.

My email address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com

My mobile number here in the Philippines is 09173084360.

Program Listing


body,p {

    .container {
        width: 450px;
        clear: both;
    .container input {
        width: 100%;
        clear: both;

	<div class="container">
<h3> Simple Interest Calculator in JavaScript </h3>
<br/>Principal (P): Php
<input type="text" id="principal" name="principal">
<br/> Rate (R):
<input type="text" id="rate" name="rate">
<br/> Time (t):
<input type="text" id="time" name="time">
<button onclick="compute_interest()">Compute Interest</button>
<p id="demo"></p>

function Commas(n) {
    var parts=n.toString().split(".")
    return parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ",") + (parts[1] ? "." + parts[1] : "");
  function compute_interest() {
    var  principal = document.getElementById("principal").value;
	var  rate = document.getElementById("rate").value;
	var  time = document.getElementById("time").value;
     rate2 = parseFloat(rate)/100;
	 amount_interest = parseFloat(principal) * (1+ (parseFloat(rate2)*time));
	 amt =amount_interest.toFixed(2);
	 display = Commas(amt);
	 results ="Amount to be paid is Php " + display+".";
      document.getElementById("demo").innerHTML = results;

Leave a Reply

Your email address will not be published. Required fields are marked *