# Future Value Calculator

The concept of future value is related to time value of money. For example, if you deposit your money in a bank as a savings account or a fixed deposit account for a certain period of time, you will earn a certain amount of money based on the compound interest computed periodically, and this amount is added to the principal if you continue to keep the money in the bank. Interest for the following period is now computed based on the initial principal plus the interest (the amount which becomes your new principal). Subsequent interests are computed in the same way.

For example, let’s say you deposited \$1000 in a bank and the bank is paying you 5% compound interest annually. After the first year, you will earn an interest of \$1000×0.05=\$50 . Your new principal will be \$1000+\$1000×0.05=\$1000(1+0.05)=\$1000(1.05)=\$1050.

After the second year, your new principal is \$1000(1.05)x1.05=\$1000(1.05)2=\$1102.50. This new principal is called the future value.

Following the above calculation, the future value after n years will be

FV = PV * (1 + i / 100)n

Where PV represents the present value, FV represents the future value, i is the interest rate and n is the number of periods (Normally months or years).

We can create a javascript function to compute the future value.  This function comprises three parameters, PV, interest rate and the number of periods, as follows:

```function FV(PV,i,n){
var x=(1+i/100)
var FV=PV*(Math.pow(x,n))
return FV;
}```

The full script is as follows:

```aaaaaa
function FV(PV,i,n){
var x=(1+i/100)
var FV=PV*(Math.pow(x,n))
return FV;
}
function Cal_FV(){
var pvalue=parseFloat(document.getElementById("a").value);
var interest=parseFloat(document.getElementById("b").value);
var num=parseInt(document.getElementById("c").value);
var fvalue=FV(pvalue, interest, num);
var fv=fvalue.toFixed(2);
document.getElementById('ans').textContent="The future value is= "+fv;
}```

The HTML document to call the Future value function is as follows:

```<!DOCTYPE html>
<html>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Future Value Calculator</title>
<body>
<h1>Future Value Calculator</h1>
<h3>Please enter the following values and click the Check Answer button to find the Future value:</h3>
<p>Present Value&nbsp;=&nbsp;&nbsp;<input type="text" size="5" id="a"></p>
<p>Interest Rate=&nbsp;<input type="text" size="5" id="b"></p>
<p>Number of Years=&nbsp;<input type="text" size="5" id="c"></p>
<h3 id="ans"><h3>
<input type="button" value="Check Answer" onclick="Cal_FV()"><br><br>
<script type="text/javascript" src="FV.js"></script>
</body>
</html>
```

Click on Future Value Calculator to view the output