



function NofY() {

e=0;

  

if (isNaN(document.compint.i.value) ||   isNaN (eval(document.compint.i.value))) {

document.compint.i.value="???"; 

alert ("Please input Interest Rate");

e=1;}

if (isNaN(document.compint.pv.value) ||   isNaN (eval(document.compint.pv.value))) {

document.compint.pv.value="???"; 

alert ("Please input Present Value");

e=1;}

if (isNaN(document.compint.fv.value) ||   isNaN (eval(document.compint.fv.value))) {

document.compint.fv.value="???"; 

alert ("Please input Future Value");

e=1;}

if (e) return;



	var fv = eval(document.compint.fv.value);



	var pv = eval(document.compint.pv.value);



	var i = eval(document.compint.i.value)/100;

               



		document.compint.years.value = Math.round(Math.log(fv/pv)*100/Math.log(1+i))/100;



}

 // N =LOG(fv/pv)/LOG(1+i)

 

function intrate()



{

e=0;

               

if (isNaN(eval(document.compint.years.value)) ||   isNaN (eval(document.compint.years.value))) {

document.compint.years.value="???"; 

alert ("Please input Number of Periods");

e=1;}

if (isNaN(document.compint.pv.value) ||   isNaN (eval(document.compint.pv.value))) {

document.compint.pv.value="???"; 

alert ("Please input Present Value");

e=1;}

if (isNaN(document.compint.fv.value) ||   isNaN (eval(document.compint.fv.value))) {

document.compint.fv.value="???"; 

alert ("Please input Future Value");

e=1;}

if (e) return;





	var fv = eval(document.compint.fv.value);

	var pv = eval(document.compint.pv.value);

	var N = eval(document.compint.years.value);

	var x = fv/pv;

	var y = 1/N;

	document.compint.i.value = Math.round ( (Math.pow(x,y) -1)*10000)/100;



} // i=((fv/pv^(1/N)-1)*100



 function c_fv()

{

e=0;

               

if (isNaN(document.compint.years.value) ||   isNaN (eval(document.compint.years.value))) {

document.compint.years.value="???"; 

alert ("Please input Number of Periods");

e=1;}

if (isNaN(document.compint.pv.value) ||   isNaN (eval(document.compint.pv.value))) {

document.compint.pv.value="???"; 

alert ("Please input Present Value");

e=1;}

if (isNaN(document.compint.i.value) ||   isNaN (eval(document.compint.i.value))) {

document.compint.i.value="???"; 

alert ("Please input Interest Rate");

e=1;}

if (e) return;





	var i = eval(document.compint.i.value)/100;

	var pv = eval(document.compint.pv.value);

	var N = eval(document.compint.years.value);

	x=1+i;

	

	document.compint.fv.value = Math.round ( pv*(Math.pow(x,N))*1000)/1000;

}



 //fv=pv*(1-i)^N

function c_pv()

{

e=0;

	

	if (isNaN(document.compint.years.value) ||   isNaN (eval(document.compint.years.value))) {

	document.compint.years.value="???"; 

	alert ("Please input Number of Periods");

	e=1;}



	if (isNaN(document.compint.fv.value) ||   isNaN (eval(document.compint.fv.value))) {

	document.compint.fv.value="???"; 

	alert ("Please input Future Value");

	e=1;}



	if (isNaN(document.compint.i.value) ||   isNaN (eval(document.compint.i.value))) {

	document.compint.i.value="???"; 

	alert ("Please input Interest Rate");

	e=1;}



	if (e) return;



	var i = eval(document.compint.i.value)/100;

	var fv = eval(document.compint.fv.value);

	var N = eval(document.compint.years.value);

	x=1+i;

	

	document.compint.pv.value = Math.round(fv/(Math.pow(x,N))*1000)/1000;



//pv=fv/(1-i)^N



}
