Skip to content

Instantly share code, notes, and snippets.

@Nasirinezhad
Last active August 10, 2019 18:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Nasirinezhad/28e6bc9eaf46749f844b8d3f631144b5 to your computer and use it in GitHub Desktop.
Save Nasirinezhad/28e6bc9eaf46749f844b8d3f631144b5 to your computer and use it in GitHub Desktop.
calculator economic factors : P/F - F/P - A/F - F/A - A/P - P/A - P/G - F/G - A/G
<html><head>
<meta charset="utf-8">
<title>calculator economic factors</title>
<script type="text/javascript">
function geti(){
n = document.getElementById('rate').value;
return Math.abs(n/100);
}
function getn(){
n = document.getElementById('turn').value;
return Math.abs(n);
}
function show(txt, tip){
n = document.getElementById('result');
n.innerHTML = txt;
n2 = document.getElementById('tip');
n2.innerHTML = tip;
}
function calfp(){
i = geti();
n = getn();
r = Math.pow(1+i, n);
show(r, 'P');
}
function calpf(){
i = geti();
n = getn();
r = Math.pow(1+i, n);
r = 1/r;
show(r, 'F');
}
function calpa(){
i = geti();
n = getn();
r = Math.pow(1+i, n);
r = (r-1)/(i*r);
show(r, 'A');
}
function calap(){
i = geti();
n = getn();
r = Math.pow(1+i, n);
r = (i*r)/(r-1);
show(r, 'P');
}
function calfa(){
i = geti();
n = getn();
p = Math.pow(1+i, n);
p = (p-1)/(i*p);
r = p*Math.pow(1+i, n);
show(r, 'A');
}
function calaf(){
i = geti();
n = getn();
p = Math.pow(1+i, n);
p = (i*p)/(p-1);
r = p/Math.pow(1+i, n);
show(r, 'F');
}
function calpg(){
i = geti();
n = getn();
p = Math.pow(1+i, n);
e = (p-1)/(i*i*p);
r = e-(n/(i*p));
show(r, 'G');
}
function calfg(){
i = geti();
n = getn();
p = Math.pow(1+i, n);
e = (p-1)/(i*i);
r = e-(n/i);
show(r, 'G');
}
function calag(){
i = geti();
n = getn();
r = Math.pow(1+i, n);
r = (i*r)/(r-1);
p = Math.pow(1+i, n);
e = (p-1)/(i*i*p);
r *= e-(n/(i*p));
show(r, 'G');
}
function equ(){
n = document.getElementById('result').innerHTML;
m = document.getElementById('cs').value;
document.getElementById('equ').innerHTML = Math.abs(n*m);
}
</script>
<style>
p, input, span, body, html{
text-align: center;
}
</style>
</head>
<body>
<p><span>i:</span><input id="rate" min="0" max="100" type="number">%</p>
<p><span>n:</span><input id="turn" min="0" type="number"> . </p>
<p id="result">0</p>
<p>
<input value="P/F" onclick="calpf()" type="button">
<input value="F/P" onclick="calfp()" type="button">
<input value="A/F" onclick="calaf()" type="button">
<input value="F/A" onclick="calfa()" type="button">
<input value="A/P" onclick="calap()" type="button">
<input value="P/A" onclick="calpa()" type="button">
</p>
<hr>
<p>
<input value="P/G" onclick="calpg()" type="button">
<input value="F/G" onclick="calfg()" type="button">
<input value="A/G" onclick="calag()" type="button">
</p>
<hr>
<p><span id="tip">*</span> <input id="cs" onkeyup="equ()" onclick="equ()" onblur="equ()" type="number"> . </p>
<p id="equ">0</p>
<i style="font-size: 8px">Marsav98@gmail.com</i><br>
<i style="font-size: 8px">+989399316839</i>
</body></html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment