# JS 05 – Best JavaScript program to calculate simple interest

## Best Javascript program to calculate simple interest

It is best and simple Javascript program to calculate simple interest.

Formula to calculate simple interest is:

Simple interest = (P x N x R)/100

P : Principle amount

N : Number of years

R : Rate of interest

### Output: Write a program to calculate simple interest using JavaScript

Simple Interest - ITVoyagers

### Javascript program to calculate simple interest

#### HTML code

```<!DOCTYPE html>
<html>
<meta charset="utf-8">
<title>Simple Interest - ITVoyagers</title>
<body>
<label>Principle</label><br>
<input type="text" id="principle" placeholder="Principle">
<br>
<label>Years</label><br>
<input type="text" id="years" placeholder="Years">
<br>
<label>Rate of Interest(%)</label><br>
<input type="text" id="roi" placeholder="Rate of the interest(%)">
<br>
<!-- itvoyagers.in -->
<button id="calculate_button" onclick="countSI()">Calculate</button>
<br>
<div id="outputdiv">
<label>Simple Interest is : <span id="outputspan"></span></label>
</div>
<script type="text/javascript" src="simpleinterest.js"></script>
<!-- itvoyagers.in -->
</body>
</html>
```

#### Javascript code (simpleinterest.js)

```var principle = document.getElementById("principle");
var roi = document.getElementById("roi");
var years = document.getElementById("years");
var outputspan = document.getElementById("outputspan");

//itvoyagers.in
function countSI()
{
p = parseFloat(principle.value);
n = parseFloat(years.value);
r = parseFloat(roi.value);
si = (p*n*r)/100;
outputspan.innerHTML = si;
}
```