雲端計算-理財規劃-純保費計算-終身壽險-女
Algo Once pseudo-code is designed to describe algorithms in local languages with VB style code.
by Chao-Yih Hsia (Mark Hsia) 2010/08
// Dx = v^x * lx |
|
|
|
|
|
|
|
|
For $i=0 to 110 |
|
|
|
|
|
|
|
|
|
Conv |
$di |
$i |
Integer |
Double |
|
|
|
|
|
$Dx[$i] = CP([利率]/100., $di) * $lx[$i] |
|
|
|
|
|
Next |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Nx = Dx + Dx+1 + … |
|
|
|
|
|
|
|
$Nx[110] = $Dx[110] |
|
|
|
|
|
|
|
|
$i=119 |
|
|
|
|
|
|
|
|
|
Loop $i>=0 |
|
|
|
|
|
|
|
|
|
$Nx[$i] = $Nx[$i+1] + $Dx[$i] |
|
|
|
|
|
|
|
$i = $i - 1 |
|
|
|
|
|
|
|
|
End Loop |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Cx = v^x+1 * dx |
|
|
|
|
|
|
|
|
For $i=0 to 110 |
|
|
|
|
|
|
|
|
|
Conv |
$di |
$i |
Integer |
Double |
|
|
|
|
|
$Cx[$i] = CP([利率]/100., $di+1) * $dn[$i] |
|
|
|
|
|
Next |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Mx = Cx + Cx+1 + … |
|
|
|
|
|
|
|
$Mx[110] = $Cx[110] |
|
|
|
|
|
|
|
|
$i=119 |
|
|
|
|
|
|
|
|
|
Loop $i>=0 |
|
|
|
|
|
|
|
|
|
$Mx[$i] = $Mx[$i+1] + $Cx[$i] |
|
|
|
|
|
|
|
$i = $i - 1 |
|
|
|
|
|
|
|
|
End Loop |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
If 1 == 0 Then |
|
|
|
|
|
|
|
|
|
{驗證結果}=`輸入資料錯誤! 投資報酬率 等於 支出成長率 ` |
|
|
|
Else |
|
|
|
|
|
|
|
|
|
|
$dpdigits = 3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
If [年齡]>110 Then |
|
|
|
|
|
|
|
|
|
[年齡] = 110 |
|
|
|
|
|
|
|
End If |
|
|
|
|
|
|
|
|
|
$d=[年齡] |
|
|
|
|
|
|
|
|
|
Conv |
$x |
$d |
Double |
Integer |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
If [年齡]+[繳付年數]>110 Then |
|
|
|
|
|
|
|
|
[繳付年數] = 110 - [年齡] |
|
|
|
|
|
|
End If |
|
|
|
|
|
|
|
|
|
$d = [年齡]+[繳付年數] |
|
|
|
|
|
|
|
Conv |
$xm |
$d |
Double |
Integer |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
If $Dx[$x] ==0 Then |
|
|
|
|
|
|
|
|
|
{驗證結果}=`輸入資料錯誤! Dx 等於 0` |
|
|
|
|
|
Else |
|
|
|
|
|
|
|
|
|
|
[躉繳純保費] = [保險金額] * $Mx[$x] / $Dx[$x] |
|
|
|
|
End If |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
If $Nx[$x] ==0 Then |
|
|
|
|
|
|
|
|
|
{驗證結果}=`輸入資料錯誤! Nx-Nx+n 等於 0` |
|
|
|
|
Else |
|
|
|
|
|
|
|
|
|
|
[年繳純保費] = [保險金額] * $Mx[$x] / $Nx[$x] |
|
|
|
|
End If |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
If $Nx[$x]-$Nx[$xm] ==0 Then |
|
|
|
|
|
|
|
|
{驗證結果}=`輸入資料錯誤! Nx-Nx+m 等於 0` |
|
|
|
|
Else |
|
|
|
|
|
|
|
|
|
|
[限期繳純保費] = [保險金額] * $Mx[$x] / ($Nx[$x]-$Nx[$xm]) |
|
|
|
End If |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
End If |
|
|
|
|
|
|
|
|
|
if $initflag==1 then |
|
|
|
|
|
|
|
|
//initialized, need to verify result |
|
|
|
|
|
|
|
|
if abs(([年繳純保費] - 515.973) / 515.973 ) < 0.001 then |
|
|
|
|
|
{驗證結果}=`` |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
|
|
|
{驗證結果}=`起始驗證錯誤, 請勿繼續使用計算結果!` |
|
|
|
|
|
|
|
|
|
|
|
|
|
end if |
|
|
|
|
|
|
|
|
end if |
|
|
|
|
|
|
|
|
|
' CopyRight (C) 2010 Chao-Yih Hsia