余采珉期末考

余采珉2021年1月期末考

現值
利率
期數
金流
終值

余采珉對照EXCEL先打開從範圍定義名稱

余采珉對照EXCEL金融計算

程式碼

<style>
h1{border: 30px outset BLUE;  
  background-color: green;  
  color: white;
  text-align: center;}
</style>
<h1>余采珉2021年1月期末考</h1>

<!--輸出現值計算結果到 td--><table border="1">
<tbody>
<tr><td>現值</td><td><input id="p" type="number" /></td><td><input onclick="CompP()" type="button" value="計算現值" /></td><td id="p_" width="160"></td></tr>
<tr><td>利率</td><td><input id="y" type="number" /></td><td><input onclick="CompP()" type="button" value="計算利率" /></td><td id="p_" width="160"></td></tr>
<tr><td>期數</td><td><input id="n" type="number" /></td><td><input onclick="CompN()" type="button" value="計算期數" /></td><td id="n_"></td></tr>
<tr><td>金流</td><td><input id="m" type="number" /></td><td><input onclick="CompM()" type="button" value="計算金流" /></td><td id="m_"></td></tr>
<tr><td>終值</td><td><input id="f" type="number" /></td><td><input onclick="CompF()" type="button" value="計算終值" /></td><td id="f_"></td></tr>
</tbody></table>

<h1>余采珉對照EXCEL先打開從範圍定義名稱</h1>
<div class="separator" style="clear: both;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj0FsEcI4n5rc58PTscc8tigzBUy1i7MbZ7_7rrZFkl2DHCP883o1thrhOMq-nFunHgYGhVvlKGYwayoD6eCtwr1ATY2HXWVHKN4-SmhR23W5OurHjoEg6rLH_8jr0eiHYD1l4D0W_xMFmh/s723/%25E6%2593%25B7%25E5%258F%2596.PNG" style="display: block; padding: 1em 0px; text-align: center;"><img alt="" border="0" data-original-height="723" data-original-width="613" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj0FsEcI4n5rc58PTscc8tigzBUy1i7MbZ7_7rrZFkl2DHCP883o1thrhOMq-nFunHgYGhVvlKGYwayoD6eCtwr1ATY2HXWVHKN4-SmhR23W5OurHjoEg6rLH_8jr0eiHYD1l4D0W_xMFmh/s320/%25E6%2593%25B7%25E5%258F%2596.PNG" /></a></div>

<h1>余采珉對照EXCEL金融計算</h1>
<div class="separator" style="clear: both;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhtJdi5m6pPNHsNr9RJUxzYdGPFJBtTpao4ZBA0AR-pLlnD3a5G4gk9_Y3zMM5AF5J07eZiIGnD7oNklR7WQZMTFJO4u3Uhfmm8X4YgRgdFVbJg6IWYvW3NCnSf2BDJu6WgGe6rgOLIPn8/s791/%25E6%2593%25B7%25E5%258F%25962.JPG" style="display: block; padding: 1em 0px; text-align: center;"><img alt="" border="0" data-original-height="403" data-original-width="791" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhtJdi5m6pPNHsNr9RJUxzYdGPFJBtTpao4ZBA0AR-pLlnD3a5G4gk9_Y3zMM5AF5J07eZiIGnD7oNklR7WQZMTFJO4u3Uhfmm8X4YgRgdFVbJg6IWYvW3NCnSf2BDJu6WgGe6rgOLIPn8/s600/%25E6%2593%25B7%25E5%258F%25962.JPG" width="600" /></a></div>

<h1>程式碼</h1>

<script>
function CompF(){
  var y = document.getElementById("y").value; //輸入
  var m = document.getElementById("m").value;
  var p = document.getElementById("p").value;
  var n = document.getElementById("n").value;
  var fvif = y;
  fvif++;          // pvif = 1+y
  pvif = fvif ** n ; //pvif = 1/(1+y)^n
  var f = p * fvif - m / y * (fvif - 1) ;
  document.getElementById("f_").innerHTML = f.toFixed(6);
}
function CompN(){    //輸入y, m, p, f 計算 n 
  var y = document.getElementById("y").value;
  var m = document.getElementById("m").value;
  var p = document.getElementById("p").value;
  var f = document.getElementById("f").value;
  var pvif = y;
  pvif++;        // pvif = 1+y
  var n = Math.log( ( f - m/y )/( p - m/y ) )/Math.log( pvif ) ;
  document.getElementById("n_").innerHTML = n.toFixed(2);
}
function CompM(){
  var y = document.getElementById("y").value;
  var n = document.getElementById("n").value;
  var p = document.getElementById("p").value;
  var f = document.getElementById("f").value;
  var pvif = y;
  pvif++;
  pvif =1/pvif**n;
  var m = y*( p - f * pvif )/( 1 - pvif ) ;
  document.getElementById("m_").innerHTML = m.toFixed(2);
}
function CompP(){
  var y = document.getElementById("y").value;
  var n = document.getElementById("n").value;
  var m = document.getElementById("m").value;
  var f = document.getElementById("f").value;
  var pvif = y;
  pvif++;
  pvif =1/pvif**n;
  var p = (1-pvif)*m/y + f * pvif;
  document.getElementById("p_").innerHTML = p.toFixed(2);
}

</script>

留言

  1. input onclick="CompP()" type="button" value="計算利率"

    忘記修改

    回覆刪除

張貼留言

這個網誌中的熱門文章

余采珉期末考UNICODE建立對照表

第八週

余采珉EXCEL資料>讀取外部資料>從web