From: Subject: TVM Calculator Date: Sun, 1 Jun 2008 11:54:17 -0400 MIME-Version: 1.0 Content-Type: multipart/related; type="text/html"; boundary="----=_NextPart_000_0000_01C8C3DE.388E3920" X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3198 This is a multi-part message in MIME format. ------=_NextPart_000_0000_01C8C3DE.388E3920 Content-Type: text/html; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable Content-Location: http://www.zenwealth.com/BusinessFinanceOnline/TVM/TVMCalcWindow.html TVM Calculator
TVM=20 Calculator
PV: $ Rate: %
PMT: $ Periods:
FV: $
=20 =20

 

=A9 2002 - 2007 by Mark A. Lane, = Ph.D.
------=_NextPart_000_0000_01C8C3DE.388E3920 Content-Type: text/css; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Location: http://www.zenwealth.com/BusinessFinanceOnline/style.css .tdratio { FONT-WEIGHT: bold; FONT-SIZE: 11px; FONT-FAMILY: Verdana, Arial, = Helvetica, sans-serif } .tdratiocat { FONT-WEIGHT: bold; FONT-SIZE: 13px; COLOR: #800000; FONT-FAMILY: = Verdana, Arial, Helvetica, sans-serif } H1 { COLOR: #800000; FONT-FAMILY: Verdana, Arial,Helvetica,sans-serif } H2 { COLOR: #800000; FONT-FAMILY: Verdana, Arial,Helvetica,sans-serif } H3 { COLOR: #800000; FONT-FAMILY: Verdana, Arial,Helvetica,sans-serif } H4 { COLOR: #800000; FONT-FAMILY: Verdana, Arial,Helvetica,sans-serif } H5 { COLOR: #800000; FONT-FAMILY: Verdana, Arial,Helvetica,sans-serif } H6 { COLOR: #800000; FONT-FAMILY: Verdana, Arial,Helvetica,sans-serif } .menu { FONT-SIZE: 11px; FONT-FAMILY: Verdana, Arial,Helvetica,sans-serif } .menubold { FONT-SIZE: 11px; COLOR: #000066; FONT-FAMILY: Verdana, Arial, = Helvetica, sans-serif } .menuheading { FONT-WEIGHT: bold; FONT-SIZE: 12px; COLOR: #800000; FONT-FAMILY: = Verdana, Arial, Helvetica, sans-serif } A:active { COLOR: #ff0000; TEXT-DECORATION: none } A:link { COLOR: #000066; TEXT-DECORATION: underline } A:visited { COLOR: #660066; TEXT-DECORATION: underline } A:hover { COLOR: #ff0000; TEXT-DECORATION: none } .small { FONT-SIZE: 11px; FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif } .whitecomic { COLOR: white; FONT-FAMILY: 'Comic Sans MS', Verdana, sans-serif } ------=_NextPart_000_0000_01C8C3DE.388E3920 Content-Type: application/octet-stream Content-Transfer-Encoding: quoted-printable Content-Location: http://www.zenwealth.com/BusinessFinanceOnline/TVM/javascripts/TVM.js function calcPV(inPMT, inFV, inNR, inNP, inC) { var outPV =3D inFV*Math.pow((1 + inNR/(100*inC)),(-inNP)); if (inNR =3D=3D 0) { outPV =3D outPV + inPMT*inNP; } else { outPV =3D outPV + inPMT*((1-(Math.pow((1 + = inNR/(100*inC)),(-inNP))))/(inNR/(100*inC))); } return outPV; } function calcFV(inPMT, inPV, inNR, inNP, inC) { var outFV =3D inPV*Math.pow((1 + inNR/(100*inC)),(inNP)); if (inNR =3D=3D 0) { outFV =3D outFV + inPMT*inNP; } else { outFV =3D outFV + inPMT*((Math.pow((1 + inNR/(100*inC)),(inNP)) - = 1)/(inNR/(100*inC))); } return outFV; } function calcPMT(inPV, inFV, inNR, inNP, inC) { var outPMT =3D 0; if (inPV !=3D 0 && inFV !=3D 0) { inPV *=3D -1; } if ((inNR > 0) && (inNP > 0)) { outPMT =3D (inPV - inFV*Math.pow(1+(inNR/(100*inC)),-inNP))/((1 - = Math.pow(1+(inNR/(100*inC)),-inNP))/(inNR/(100*inC))); if (inFV !=3D 0) { outPMT *=3D -1; } =20 } else if ((inNR =3D=3D 0) && (inNP > 0)) { outPMT =3D (inPV - inFV)/inNP; if (inFV !=3D 0) { outPMT *=3D -1; } =20 } else { alert("The number of periods must be greater than 0."); outPMT =3D ""; } return outPMT; } function calcNR(inPMT, inPV, inFV, inNP, inC) { var outNR =3D 0.1; // initial guess var thePV1, thePV2, theDeriv; var theH =3D 0.00001; var i =3D 1; var theZeros =3D 0; var lastNR =3D outNR; //alert("PV " + inPV + " PMT " + inPMT + " FV " + inFV + " NP " + = inNP); if (inNP <=3D 0) { // should throw an exception alert("The Nominal Rate cannot be computed."); return outNR =3D ""; } if (inFV =3D=3D 0) { theZeros++; }=09 if (inPMT =3D=3D 0) { theZeros++; }=09 if (inPV =3D=3D 0) { theZeros++; // inFV *=3D -1; } if (theZeros >=3D 2) { // should throw an exception alert("The Nominal Rate cannot be computed."); return outNR =3D ""; } if ((inPV > 0) && (inPMT >=3D 0) && (inFV >=3D 0)) { alert("The Nominal Rate cannot be computed."); return outNR =3D ""; } if ((inPV =3D=3D 0) && (inPMT >=3D 0) && (inFV >=3D 0)) { alert("The Nominal Rate cannot be computed."); return outNR =3D ""; } inPV *=3D -1; //thePV1 =3D calcPV(inPMT,inFV,outNR*100,inNP,inC); //alert("thePV1 " + thePV1 + " " + inPV); do { thePV1 =3D calcPV(inPMT,inFV,(outNR*100),inNP,inC) - inPV; theDeriv =3D ((calcPV(inPMT,inFV,((outNR+theH)*100),inNP,inC) - inPV) = - thePV1)/theH; thePV2 =3D thePV1; //if ((theDeriv =3D=3D 0) && (Math.abs(thePV2) > 0)) { // should throw = an exception // alert("The Nominal Rate cannot be computed. 5"); // return outNR =3D ""; //} lastNR =3D outNR; outNR =3D outNR - thePV1/theDeriv; if (i > 200) { // should throw an exception alert("The Nominal Rate cannot be computed."); return outNR =3D ""; } i++; if (thePV2 < 0) thePV2 *=3D -1; } while (thePV2 > 0.0001); return (lastNR*100); // maybe should change to give the previous rate=09 } function calcNP(inPMT, inPV, inFV, inNR, inC) { var outNP =3D 5; // initial guess var lastNP =3D outNP; var thePV1, thePV2, theDeriv; var theH =3D 0.001; var i =3D 1; var theZeros =3D 0; =09 if (inNR <=3D 0) { // should throw an exception alert("The Number of Periods cannot be computed."); return outNP =3D ""; } if (inFV =3D=3D 0) { theZeros++; }=09 if (inPMT =3D=3D 0) { theZeros++; }=09 if (inPV =3D=3D 0) { theZeros++; } if (theZeros >=3D 2) { // should throw an exception alert("The Number of Periods cannot be computed."); return outNP =3D ""; } if ((inPV > 0) && (inPMT >=3D 0) && (inFV >=3D 0)) { alert("The Number of Periodscannot be computed."); return outNP =3D ""; } if ((inPV =3D=3D 0) && (inPMT >=3D 0) && (inFV >=3D 0)) { alert("The Number of Periods cannot be computed."); return outNP =3D ""; } inPV *=3D -1; if ((inPV =3D=3D inFV) && ((inNR/(100*inC))*inFV =3D=3D inPMT)) { // = should throw an exception alert("The Number of Periods is not unique."); return outNP =3D "";// outNP can be any number } do { thePV1 =3D calcPV(inPMT,inFV,inNR,outNP,inC) - inPV; theDeriv =3D ((calcPV(inPMT,inFV,inNR,outNP+theH,inC) - inPV) - = thePV1)/theH; thePV2 =3D thePV1; //if (theDeriv =3D=3D 0) { // should throw an exception // return outN; //} lastNP =3D outNP; outNP =3D outNP - thePV1/theDeriv; if (i > 200) { // should throw an exception alert("The Number of Periods cannot be computed."); return outNP =3D ""; } i++; } while (Math.abs(thePV2) > 0.0001); return lastNP;=09 } function findPV(form) { var theFV =3D form.FVInput.value; if (!isNumber(theFV)) { return false; } if (theFV =3D=3D "") theFV =3D 0; var thePMT =3D form.PMTInput.value; if (!isNumber(thePMT)) { return false; } if (thePMT =3D=3D "") thePMT =3D 0; var theNP =3D form.NPInput.value; if (!isPositiveNumber(theNP)) { return false; } if (theNP =3D=3D "") theNP =3D 0; var theNR =3D form.NRInput.value; if (!isPositiveNumber(theNR)) { return false; } if (theNR =3D=3D "") theNR =3D 0; var theC; var theCompounding =3D form.CInput.selectedIndex; if (theCompounding =3D=3D 0) { theC =3D 1; } else if (theCompounding =3D=3D 1) { theC =3D 2; } else if (theCompounding =3D=3D 2) { theC =3D 4; } else if (theCompounding =3D=3D 3) { theC =3D 12; } else if (theCompounding =3D=3D 4) { theC =3D 52; } else if (theCompounding =3D=3D 5) { theC =3D 365; } var thePV =3D calcPV(thePMT, theFV, theNR, theNP, theC); form.PVInput.value =3D "" + Math.round(-thePV*100)/100; return true; } =20 function findPMT(form) { var thePV =3D form.PVInput.value; if (!isNumber(thePV)) { return false; } if (thePV =3D=3D "") thePV =3D 0; var theFV =3D form.FVInput.value; if (!isNumber(theFV)) { return false; } if (theFV =3D=3D "") theFV =3D 0;=09 var theNP =3D form.NPInput.value; if (!isPositiveNumber(theNP)) { return false; } if (theNP =3D=3D "") theNP =3D 0; var theNR =3D form.NRInput.value; if (!isPositiveNumber(theNR)) { return false; } if (theNR =3D=3D "") theNR =3D 0; var theC; var theCompounding =3D form.CInput.selectedIndex; if (theCompounding =3D=3D 0) { theC =3D 1; } else if (theCompounding =3D=3D 1) { theC =3D 2; } else if (theCompounding =3D=3D 2) { theC =3D 4; } else if (theCompounding =3D=3D 3) { theC =3D 12; } else if (theCompounding =3D=3D 4) { theC =3D 52; } else if (theCompounding =3D=3D 5) { theC =3D 365; } var thePMT =3D calcPMT(thePV, theFV, theNR, theNP, theC); if (thePMT =3D=3D "") { form.PMTInput.value =3D ""; } else { form.PMTInput.value =3D "" + Math.round(-thePMT*100)/100; } return true; } function findFV(form) { var thePV =3D form.PVInput.value; if (!isNumber(thePV)) { return false; } if (thePV =3D=3D "") thePV =3D 0; var thePMT =3D form.PMTInput.value; if (!isNumber(thePMT)) { return false; } if (thePMT =3D=3D "") thePMT =3D 0; var theNP =3D form.NPInput.value; if (!isPositiveNumber(theNP)) { return false; } if (theNP =3D=3D "") theNP =3D 0; var theNR =3D form.NRInput.value; if (!isPositiveNumber(theNR)) { return false; } if (theNR =3D=3D "") theNR =3D 0; var theC; var theCompounding =3D form.CInput.selectedIndex; if (theCompounding =3D=3D 0) { theC =3D 1; } else if (theCompounding =3D=3D 1) { theC =3D 2; } else if (theCompounding =3D=3D 2) { theC =3D 4; } else if (theCompounding =3D=3D 3) { theC =3D 12; } else if (theCompounding =3D=3D 4) { theC =3D 52; } else if (theCompounding =3D=3D 5) { theC =3D 365; } var theFV =3D calcFV(thePMT, thePV, theNR, theNP, theC); form.FVInput.value =3D "" + Math.round(-theFV*100)/100; return true; } =20 function findNR(form) { var theFV =3D form.FVInput.value; if (!isNumber(theFV)) { return false; } if (theFV =3D=3D "") theFV =3D 0; var thePMT =3D form.PMTInput.value; if (!isNumber(thePMT)) { return false; } if (thePMT =3D=3D "") thePMT =3D 0; var theNP =3D form.NPInput.value; if (!isPositiveNumber(theNP)) { return false; } if (theNP =3D=3D "") theNP =3D 0; var thePV =3D form.PVInput.value; if (!isNumber(thePV)) { return false; } if (thePV =3D=3D "") thePV =3D 0; var theC; var theCompounding =3D form.CInput.selectedIndex; if (theCompounding =3D=3D 0) { theC =3D 1; } else if (theCompounding =3D=3D 1) { theC =3D 2; } else if (theCompounding =3D=3D 2) { theC =3D 4; } else if (theCompounding =3D=3D 3) { theC =3D 12; } else if (theCompounding =3D=3D 4) { theC =3D 52; } else if (theCompounding =3D=3D 5) { theC =3D 365; } var theNR =3D calcNR(thePMT, thePV, theFV, theNP, theC); if (theNR =3D=3D "") { form.NRInput.value =3D ""; } else { form.NRInput.value =3D "" + Math.round(theNR*100)/100; } return true; } function findNP(form) { var theFV =3D form.FVInput.value; if (!isNumber(theFV)) { return false; } if (theFV =3D=3D "") theFV =3D 0; var thePMT =3D form.PMTInput.value; if (!isNumber(thePMT)) { return false; } if (thePMT =3D=3D "") thePMT =3D 0; var theNR =3D form.NRInput.value; if (!isPositiveNumber(theNR)) { return false; } if (theNR =3D=3D "") theNR =3D 0; var thePV =3D form.PVInput.value; if (!isNumber(thePV)) { return false; } if (thePV =3D=3D "") thePV =3D 0; var theC; var theCompounding =3D form.CInput.selectedIndex; if (theCompounding =3D=3D 0) { theC =3D 1; } else if (theCompounding =3D=3D 1) { theC =3D 2; } else if (theCompounding =3D=3D 2) { theC =3D 4; } else if (theCompounding =3D=3D 3) { theC =3D 12; } else if (theCompounding =3D=3D 4) { theC =3D 52; } else if (theCompounding =3D=3D 5) { theC =3D 365; } var theNP =3D calcNP(thePMT, thePV, theFV, theNR, theC); if (theNP =3D=3D "") { form.NPInput.value =3D ""; } else { form.NPInput.value =3D "" + Math.round(theNP*100)/100; } return true; } =20 function isPositiveNumber(inputStr) { var decFlag =3D false; if (inputStr =3D=3D ".") { alert("Please make sure that only numbers are input."); return false; } for (var i =3D 0; i < inputStr.length; i++) { var oneChar =3D inputStr.substring(i,i+1); if (((oneChar >=3D "0") && (oneChar <=3D "9")) || ((oneChar =3D=3D = ".") && (decFlag =3D=3D false))) { =09 } else { alert("Please make sure that only numbers are input."); return false; } if (oneChar =3D=3D ".") { decFlag =3D true; } } return true; } =20 function isNumber(inputStr) { var decFlag =3D false; if (inputStr =3D=3D ".") { alert("Please make sure that only numbers are input."); return false; } for (var i =3D 0; i < inputStr.length; i++) { var oneChar =3D inputStr.substring(i,i+1); if ((i =3D=3D 0) && (inputStr.length > 1)) { if (((oneChar >=3D "0") && (oneChar <=3D "9")) || ((oneChar =3D=3D = ".") && (decFlag =3D=3D false)) || (oneChar =3D=3D "-")) { =09 } else { alert("Please make sure that only numbers are input."); return false; } } else { if (((oneChar >=3D "0") && (oneChar <=3D "9")) || ((oneChar =3D=3D = ".") && (decFlag =3D=3D false))) { =09 } else { alert("Please make sure that only numbers are input."); return false; } } if (oneChar =3D=3D ".") { decFlag =3D true; }=09 } return true; } =20 function launchTVMCalc() { = window.open("TVMCalcWindow.html","Win2","menubar,resizable,height=3D205,w= idth=3D315"); } ------=_NextPart_000_0000_01C8C3DE.388E3920--