<?php
require("calldata.php");
$sql = "SELECT * FROM plan";
$result = mysql_query($sql, $link);
while( $row = mysql_fetch_row( $result ) ){
$plan = $row[0];
}
$sql = "SELECT * FROM policy";
$result = mysql_query($sql, $link);
$n=1;
while( $row = mysql_fetch_row( $result ) ){
$matrix[$n][1] = $row[0];
$matrix[$n][2] =$row[1];
$matrix[$n][3] =$row[2];
$matrix[$n][4] =$row[3];
$n=$n+1;
}
$maxn=$n;
for ($n=1;$n<$maxn;$n++){
$num=$matrix[$n][1];
$px1[$num]=$matrix[$n][2];
$px2[$num]=$matrix[$n][3];
$px3[$num]=$matrix[$n][4];
}
$p = $px1[$plan];
$g = $px2[$plan];
$r= $px3[$plan];
$sql = "SELECT * FROM eli98";
$result = mysql_query($sql, $link);
$n=1;
while( $row = mysql_fetch_row( $result ) ){
$matrix[$n][1] = $row[0];
$matrix[$n][2] =$row[1];
$matrix[$n][3] =$row[2];
$matrix[$n][4] =$row[3];
$n=$n+1;
}
$maxn=$n;
for ($n=1; $n < $maxn; $n++) {
$year =$matrix[$n][1];
$age =$matrix[$n][2];
$mgen[$year][$age] = $matrix[$n][3];
$fgen[$year][$age] = $matrix[$n][4];
}
$sql = "SELECT * FROM eli77";
$result = mysql_query($sql, $link);
$n=1;
while( $row = mysql_fetch_row( $result ) ){
$matrix[$n][1] = $row[0];
$matrix[$n][2] =$row[1];
$n=$n+1;
}
$maxn=$n;
for ($n=1; $n < $maxn; $n++) {
$byear =$matrix[$n][1];
$jyo[$byear] = $matrix[$n][2];
}
$price[10]=1;
for ($year=11;$year<100;$year++){
$price[$year]=(1+$g)*$price[$year-1];
}
for ($year=10;$year<100;$year++){
$e1=0;
for ($age=20;$age<100;$age++){
$byear=$year-$age+2000;
$syear=$byear;
if ($syear<1950)$syear=1950;
$e1=0;
$e1=$e1+0.75*260*$price[$year]*2*25*$mgen[$year][$age]*$jyo[$byear]/1000;
$e1=$e1+0.75*220*$price[$year]*1.3*25*$fgen[$year][$age]*$jyo[$byear]/1000;
$gen[$year][$age]=$e1/10000;
}
}
$sql = "truncate eli101";
$exe= mysql_query($sql,$link);
for ($year=10;$year<100;$year++){
for ($age=20;$age<100;$age++){
$x=$gen[$year][$age];
$sql = "insert into eli101 values($year,$age,$x)";
$exe= mysql_query($sql,$link);
}
}
$close_flag = mysql_close($link);
print("101 世代基礎現役遺族 計算終了");
?>
最終更新:2010年08月31日 01:10