簡佩芝期末考1月7日

簡佩芝2021年1月7號期末考

現值
利率
期數
金流
終值

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

對照EXCEL金融計算

程式碼

css顏色參考拷貝自維基百科




粉紅色系
PinkFF C0 CB255 192 203
LightPinkFF B6 C1255 182 193
HotPinkFF 69 B4255 105 180
DeepPinkFF 14 93255 20 147
PaleVioletRedDB 70 93219 112 147
MediumVioletRedC7 15 85199 21 133
Purple80 00 80128 0 128
LavenderE6 E6 FA230 230 250
ThistleD8 BF D8216 191 216
PlumDD A0 DD221 160 221
VioletEE 82 EE238 130 238
OrchidDA 70 D6218 112 214
FuchsiaFF 00 FF255 0 255
MagentaFF 00 FF255 0 255
MediumOrchidBA 55 D3186 85 211
MediumPurple93 70 DB147 112 219
Amethyst99 66 CC153 102 204
BlueViolet8A 2B E2138 43 226
DarkViolet94 00 D3148 0 211
DarkOrchid99 32 CC153 50 204
DarkMagenta8B 00 8B139 0 139
MediumSlateBlue7B 68 EE123 104 238
SlateBlue6A 5A CD106 90 205
DarkSlateBlue48 3D 8B72 61 139
Indigo4B 00 8275 0 130

程式碼

<style>
h1{border: 25px outset LightPink;  
  background-color: MediumPurple;  
  color: white;
  text-align: center;}
</style>
<h1>簡佩芝2021年1月7號期末考</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" value="0.001"/></td><td><input onclick="CompY()" type="button" value="計算利率" /></td><td id="y_"></td></tr>
<tr><td>期數</td><td><input id="n" type="number" value="240"/></td><td><input onclick="CompN()" type="button" value="計算期數" /></td><td id="n_"></td></tr>
<tr><td>金流</td><td><input id="m" type="number" value="0"/></td><td><input onclick="CompM()" type="button" value="計算金流" /></td><td id="m_"></td></tr>
<tr><td>終值</td><td><input id="f" type="number" value="0"/></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/AVvXsEiE5hZbr5sUKvq231Z3AZ27_K2hMjDGiBOp4SP3ECnzJ9-2ahuET6MsGtQ7QG0iK2JJ0EnZLyBFO8N4MEZbB1-iDpoUsfJXsBiW0jLD2puMHFAfbdL7WB5wvw02JmeqRtqZzrBnT4tb_DRF/s755/111111111111111111111.PNG" style="display: block; padding: 1em 0; text-align: center; "><img alt="" border="0" width="600" data-original-height="262" data-original-width="755" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiE5hZbr5sUKvq231Z3AZ27_K2hMjDGiBOp4SP3ECnzJ9-2ahuET6MsGtQ7QG0iK2JJ0EnZLyBFO8N4MEZbB1-iDpoUsfJXsBiW0jLD2puMHFAfbdL7WB5wvw02JmeqRtqZzrBnT4tb_DRF/s600/111111111111111111111.PNG"/></a></div>

<h1>對照EXCEL金融計算</h1>
<div class="separator" style="clear: both;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi8srH6cdI_NH-F8uoOeP4NCXZbv_IgLwy9me1oCd4anJttcn0AXua0bzP5EdpSFEFADEiKoLZ0Klm_spL-VyDRC35iwTH9eGzqWg_9EMVi8JRNLmj8-7mnZ4RF41rTdZ1gnU6j6QU9KUFQ/s567/22222222222222222222.PNG" style="display: block; padding: 1em 0; text-align: center; "><img alt="" border="0" width="600" data-original-height="337" data-original-width="567" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi8srH6cdI_NH-F8uoOeP4NCXZbv_IgLwy9me1oCd4anJttcn0AXua0bzP5EdpSFEFADEiKoLZ0Klm_spL-VyDRC35iwTH9eGzqWg_9EMVi8JRNLmj8-7mnZ4RF41rTdZ1gnU6j6QU9KUFQ/s600/22222222222222222222.PNG"/></a></div>

<h1>程式碼</h1><h1 style="text-align: left;">css顏色參考拷貝自<a href="https://zh.wikipedia.org/wiki/%E7%BD%91%E9%A1%B5%E9%A2%9C%E8%89%B2" target="_blank">維基百科</a></h1><div><br /></div><div><br /></div><div><br /></div><div><table border="0" style="background-color: white; color: #202122; font-family: sans-serif; font-size: 12.0064px;"><tbody><tr><td colspan="3" style="background: whitesmoke; color: slategrey;"><big style="font-size: 1.143em;"><b>粉紅色系</b></big></td></tr><tr style="background: pink; color: black;"><td>Pink</td><td><tt style="font-family: monospace, monospace;">FF C0 CB</tt></td><td><tt style="font-family: monospace, monospace;">255 192 203</tt></td></tr><tr style="background: lightpink; color: black;"><td>LightPink</td><td><tt style="font-family: monospace, monospace;">FF B6 C1</tt></td><td><tt style="font-family: monospace, monospace;">255 182 193</tt></td></tr><tr style="background: hotpink; color: white;"><td>HotPink</td><td><tt style="font-family: monospace, monospace;">FF 69 B4</tt></td><td><tt style="font-family: monospace, monospace;">255 105 180</tt></td></tr><tr style="background: deeppink; color: white;"><td>DeepPink</td><td><tt style="font-family: monospace, monospace;">FF 14 93</tt></td><td><tt style="font-family: monospace, monospace;">255 20 147</tt></td></tr><tr style="background: palevioletred; color: white;"><td>PaleVioletRed</td><td><tt style="font-family: monospace, monospace;">DB 70 93</tt></td><td><tt style="font-family: monospace, monospace;">219 112 147</tt></td></tr><tr style="background: mediumvioletred; color: white;"><td>MediumVioletRed</td><td><tt style="font-family: monospace, monospace;">C7 15 85</tt></td><td><tt style="font-family: monospace, monospace;">199 21 133</tt></td></tr></tbody></table><table border="0" style="background-color: white; color: #202122; font-family: sans-serif; font-size: 12.0064px;"><tbody><tr style="background: purple; color: white;"><td>Purple</td><td><tt style="font-family: monospace, monospace;">80 00 80</tt></td><td><tt style="font-family: monospace, monospace;">128 0 128</tt></td></tr><tr style="background: lavender; color: black;"><td>Lavender</td><td><tt style="font-family: monospace, monospace;">E6 E6 FA</tt></td><td><tt style="font-family: monospace, monospace;">230 230 250</tt></td></tr><tr style="background: thistle; color: black;"><td>Thistle</td><td><tt style="font-family: monospace, monospace;">D8 BF D8</tt></td><td><tt style="font-family: monospace, monospace;">216 191 216</tt></td></tr><tr style="background: plum; color: black;"><td>Plum</td><td><tt style="font-family: monospace, monospace;">DD A0 DD</tt></td><td><tt style="font-family: monospace, monospace;">221 160 221</tt></td></tr><tr style="background: violet; color: black;"><td>Violet</td><td><tt style="font-family: monospace, monospace;">EE 82 EE</tt></td><td><tt style="font-family: monospace, monospace;">238 130 238</tt></td></tr><tr style="background: orchid; color: white;"><td>Orchid</td><td><tt style="font-family: monospace, monospace;">DA 70 D6</tt></td><td><tt style="font-family: monospace, monospace;">218 112 214</tt></td></tr><tr style="background: fuchsia; color: white;"><td>Fuchsia</td><td><tt style="font-family: monospace, monospace;">FF 00 FF</tt></td><td><tt style="font-family: monospace, monospace;">255 0 255</tt></td></tr><tr style="background: magenta; color: white;"><td>Magenta</td><td><tt style="font-family: monospace, monospace;">FF 00 FF</tt></td><td><tt style="font-family: monospace, monospace;">255 0 255</tt></td></tr><tr style="background: mediumorchid; color: white;"><td>MediumOrchid</td><td><tt style="font-family: monospace, monospace;">BA 55 D3</tt></td><td><tt style="font-family: monospace, monospace;">186 85 211</tt></td></tr><tr style="background: mediumpurple; color: white;"><td>MediumPurple</td><td><tt style="font-family: monospace, monospace;">93 70 DB</tt></td><td><tt style="font-family: monospace, monospace;">147 112 219</tt></td></tr><tr style="background: rgb(153, 102, 204); color: white;"><td>Amethyst</td><td><tt style="font-family: monospace, monospace;">99 66 CC</tt></td><td><tt style="font-family: monospace, monospace;">153 102 204</tt></td></tr><tr style="background: blueviolet; color: white;"><td>BlueViolet</td><td><tt style="font-family: monospace, monospace;">8A 2B E2</tt></td><td><tt style="font-family: monospace, monospace;">138 43 226</tt></td></tr><tr style="background: darkviolet; color: white;"><td>DarkViolet</td><td><tt style="font-family: monospace, monospace;">94 00 D3</tt></td><td><tt style="font-family: monospace, monospace;">148 0 211</tt></td></tr><tr style="background: darkorchid; color: white;"><td>DarkOrchid</td><td><tt style="font-family: monospace, monospace;">99 32 CC</tt></td><td><tt style="font-family: monospace, monospace;">153 50 204</tt></td></tr><tr style="background: darkmagenta; color: white;"><td>DarkMagenta</td><td><tt style="font-family: monospace, monospace;">8B 00 8B</tt></td><td><tt style="font-family: monospace, monospace;">139 0 139</tt></td></tr><tr style="background: mediumslateblue; color: white;"><td>MediumSlateBlue</td><td><tt style="font-family: monospace, monospace;">7B 68 EE</tt></td><td><tt style="font-family: monospace, monospace;">123 104 238</tt></td></tr><tr style="background: slateblue; color: white;"><td>SlateBlue</td><td><tt style="font-family: monospace, monospace;">6A 5A CD</tt></td><td><tt style="font-family: monospace, monospace;">106 90 205</tt></td></tr><tr style="background: darkslateblue; color: white;"><td>DarkSlateBlue</td><td><tt style="font-family: monospace, monospace;">48 3D 8B</tt></td><td><tt style="font-family: monospace, monospace;">72 61 139</tt></td></tr><tr style="background: indigo; color: white;"><td>Indigo</td><td><tt style="font-family: monospace, monospace;">4B 00 82</tt></td><td><tt style="font-family: monospace, monospace;">75 0 130</tt></td></tr></tbody></table></div>

<h1>程式碼</h1>


<script>
function CompY(){
document.getElementById("y_").innerHTML = "明年重修再來寫";
  }
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>

留言