<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>PCX Payroll System</title>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
</head>
<body>
<b>FICA.pm</b><br>
<br>
FICA->calculate( <br>
gross, # gross pay<br>
date, # date of payment<br>
YTD # total FICA payments made year
to date<br>
)<br>
{<br>
iterate over sorted keys descending in data hash. <br>
Compare $date to keys. <br>
Stop when $date >= key. <br>
set $foundDate = $key. <br>
If date < all keys, that is an error. <br>
<br>
my $cap = data{$foundDate}->{cap}<br>
my $rate = data{$foundDate}->{rate}<br>
if (YTD >= $cap)<br>
return 0<br>
else<br>
{<br>
fica = rate * gross<br>
if (fica + YTD <= cap)<br>
return fica<br>
else<br>
return (cap - YTD)
* rate<br>
}<br>
}<br>
<br>
<table cellpadding="2" cellspacing="2" border="0" width="30%">
<tbody>
<tr>
<td valign="Top">data{$foundDate}-><br>
</td>
<td valign="Top">{rate}<br>
</td>
</tr>
<tr>
<td valign="Top">ex. data{20010101}-><br>
</td>
<td valign="Top">{cap}<br>
</td>
</tr>
</tbody>
</table>
<br>
sub new()<br>
{<br>
#create tables for lookup<br>
data{<br>
'19990101' => {rate => 0.0565, cap => 68000},<br>
'20010101' => {rate => 0.0565, cap => 72000}<br>
} <br>
}<br>
</body>
</html>