Calculator
echo ““;
if(isset($_REQUEST[‘Month’]) && $_REQUEST[‘Month’] != “–“)
{
$selected_month = $_REQUEST[“Month”];
}
if(isset($_REQUEST[‘Year’]))
{
$selected_year = $_REQUEST[‘Year’];
}
echo “1. Select Month:
foreach(array_keys($months) as $month)
{
if(isset($selected_month) and $month == $selected_month)
{
echo “
$month
\n”;
}
else
{
if(isset($selected_month) and $month == “–“)
{
continue;
}
echo “
$month
\n”;
}
}
echo “
“;
echo “
2. Select Day:
if(isset($selected_month))
{
for($day = 1; $day <= $months[$selected_month]; $day++)
{
echo “
$day
\n”;
}
}
else
{
echo “
—
\n”;
}
echo “
“;
echo “
3. Select Year:
for($year = $min_year; $year <= $max_year; $year++)
{
if(isset($selected_year) && $year == $selected_year)
{
echo “
$year
\n”;
}
else
{
echo “
$year
\n”;
}
}
echo “
“;
echo “
4. Enter Your Full Age Retirement Amount: $“;
echo “
“;
echo “
“;
echo ” \n”;
}
else
{
//echo “Calculate here “.$_REQUEST[‘Month’].” “. $_REQUEST[‘Day’].” “.$_REQUEST[‘Year’].”
“;
// Full age – 3 years (36 months) = 20% (.55556% / month)
// Full age – +3 years = 5% / year (.41666% / month)
$birth_year = $_REQUEST[‘Year’];
$birth_month = $_REQUEST[‘Month’];
$birth_day = $_REQUEST[‘Day’];
$input_amount = $_REQUEST[‘Input’];
//If birth day is January 1st or 2nd, subtract a year
echo “You input $birth_month $birth_day $birth_year with a contribution of
\$$input_amount – Reset
“;
if($birth_month == “January” && $birth_day == 1 )
{
$birth_year–;
}
$full_retirement_age = array(1938 => 36, 1939 => 38, 1940 => 40, 1941 => 42,
1942 => 44, 1943 => 46, 1955 => 48, 1956 => 50,
1957 => 52, 1958 => 54, 1959 => 56, 1960 => 58,
2008 => 60);
foreach(array_keys($full_retirement_age) as $years)
{
if(isset($months_until_full))
{
continue;
}
if($birth_year < $years)
{
$months_until_full = $full_retirement_age[$years];
}
}
//echo “months in retirmeent = $months_until_full
“;
$min_age = 62;
$mulitiplier = 1;
$percent_off = 0;
$full_age_month = $months_until_full % 12;
$full_age_year = 62 + (($months_until_full – ($months_until_full % 12)) / 12);
//echo “full age is $full_age_year years $full_age_month months
“;
echo “
“;
echo “
Months Until Full AgeAge of RetirementPercent
ReceivedReduced Benefit Amount
\n”;
// If birthday is the 1st or 2nd, subtract a month
if($birth_day != 1 && $birth_day != 2)
{
$months_until_full–;
}
for($line = $months_until_full; $line >= 0; $line–)
{
if($line == $months_until_full)
{
$percent_off = 0;
}
elseif($line >= $months_until_full – 36)
{
$percent_off = $percent_off+.55555555556;
}
else
{
$percent_off = $percent_off+.4166666666667;
}
if($full_age_month == 0)
{
$output_line = “$full_age_year years”;
$full_age_year–;
$full_age_month = 11;
}
else
{
$output_line = “$full_age_year years $full_age_month months”;
$full_age_month–;
}
$output_percent = 100 – $percent_off;
$output_months = $months_until_full – $line;
$output_percent = sprintf(‘%01.4f’, $output_percent);
$output_value = $input_amount * $output_percent / 100;
$output_percent = sprintf(‘%01.1f’, $output_percent);
$output_value = floor($output_value);
echo
“
$output_months$output_line$output_percent%\$$output_value
\n”;
//echo $output_line.” – $output_percent
“;
}
echo “
\n”;
}
?>