VB icon

Simple Interest Rate Calculator in JavaScript

Email
Submitted on: 11/16/2015 12:45:19 PM
By: Jake R. Pomperada  
Level: Beginner
User Rating: Unrated
Compatibility: JavaScript
Views: 6664
author picture
 
     A sample program that I wrote the will compute the interest rate of a loan I called this program simple interest rate calculator written in JavaScript. If you have some questions please send me an email at jake.r.pomperada@gmail.com and jakerpomperada@yahoo.com. My mobile number here in the Philippines is 09173084360.

 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
				
'**************************************
' Name: Simple Interest Rate Calculator in JavaScript
' Description:A sample program that I wrote the will compute the interest rate of a loan I called this program simple interest rate calculator written in JavaScript.
If you have some questions please send me an email at jake.r.pomperada@gmail.com and jakerpomperada@yahoo.com. 
My mobile number here in the Philippines is 09173084360.
' By: Jake R. Pomperada
'**************************************

<html>
<style>
body,p {
 font-family:arial;
 font-size:16px;
 font-weight:bolder;
 }
 
.container {
width: 350px;
clear: both;
}
.container input {
width: 100%;
clear: both;
}
</style>
	<div class="container">
<body>
<h3> Simple Interest Calculator </h3>
<br/>Principal (P): Php
<input type="text" id="principal" name="principal">
<br>
<br/> Rate (R):
<input type="text" id="rate" name="rate">
<br>
<br/> Time (t):
<input type="text" id="time" name="time">
<br>
<br>
<button onclick="compute_interest()">Compute Interest</button>
<br><br>
<p id="demo"></p>
</div>
<script>
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;
 }
</script>
</body>
</html>


Other 108 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Beginner category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.