# Present value of an annuity calculator

Posted in: Capital budgeting techniques (calculators)

Periodic payment:

Number of Periods:

Interest Rate:

Skip to content
# Present value of an annuity calculator

function myFunction()
{
var x;
var y;
var z;
var errors;
x=pp.value;
y=nop.value;
z=ir.value;
x=x.replace(/[^0-9.]/g, '');
y=y.replace(/[^0-9.]/g, '');
z=z.replace(/[^0-9.]/g, '');
x=parseFloat(x);
y=parseFloat(y);
z=parseFloat(z);
presentvalueofanannuity=x*(1-Math.pow(1+z/100, -y))/(z/100);
if (x=="0")
{
document.getElementById("error1").innerHTML="This field cannot be zero.";
errors=true;
}
else if (pp.value=="")
{
document.getElementById("error1").innerHTML="This field cannot be blank.";
errors=true;
}
else {
document.getElementById("error1").innerHTML="";
}
if (y=="0")
{
document.getElementById("error2").innerHTML="This field cannot be zero.";
errors=true;
}
else if (nop.value=="")
{
document.getElementById("error2").innerHTML="This field cannot be blank.";
errors=true;
}
else {
document.getElementById("error2").innerHTML="";
}
if (z=="0")
{
document.getElementById("error3").innerHTML="This field cannot be zero.";
errors=true;
}
else if (ir.value=="")
{
document.getElementById("error3").innerHTML="This field cannot be blank.";
errors=true;
}
else {
document.getElementById("error3").innerHTML="";
}
if (errors==true)
{
document.getElementById("pvoaa").innerHTML="";
return false;
errors=false;
}
if (isNaN(presentvalueofanannuity))
{
presentvalueofanannuity = "0";
}
if (presentvalueofanannuity == Number.POSITIVE_INFINITY || presentvalueofanannuity == Number.NEGATIVE_INFINITY)
{
presentvalueofanannuity="0";
}
presentvalueofanannuity = parseFloat(presentvalueofanannuity);
presentvalueofanannuity = Math.round(presentvalueofanannuity*100)/100;
presentvalueofanannuity = presentvalueofanannuity.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
document.getElementById("loading").style.visibility = "visible";
setTimeout(function(){Timer1()},1200);
}
function Timer1() {
document.getElementById("loading").style.visibility = "hidden";
document.getElementById("pvoaa").innerHTML="Present value of annuity: "+"$"+presentvalueofanannuity;
}
function reset()
{
pp.value="";
nop.value="";
ir.value="";
document.getElementById("pvoaa").innerHTML="";
document.getElementById("error1").innerHTML="";
document.getElementById("error2").innerHTML="";
document.getElementById("error3").innerHTML="";
}

Menu

Find

Posted in: Capital budgeting techniques (calculators)

Periodic payment:

Number of Periods:

Interest Rate:

Copyright 2012 - 2021. Accounting For Management

## Leave a comment