<!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-&gt;calculate( <br>
&nbsp;&nbsp;&nbsp; gross, &nbsp;# gross pay<br>
&nbsp;&nbsp;&nbsp; date, &nbsp;&nbsp; # date of payment<br>
&nbsp;&nbsp;&nbsp; YTD&nbsp;&nbsp;&nbsp; # total FICA payments made year
to date<br>
)<br>
{<br>
&nbsp;&nbsp;iterate over sorted keys descending in data hash. &nbsp;<br>
&nbsp; &nbsp; Compare $date to keys. &nbsp;<br>
&nbsp; &nbsp; Stop when $date &gt;= key. &nbsp;<br>
&nbsp; &nbsp; set $foundDate = $key. <br>
&nbsp; &nbsp; If date &lt; all keys, that is an error. &nbsp; <br>
<br>
&nbsp; my $cap = data{$foundDate}-&gt;{cap}<br>
&nbsp; my $rate = data{$foundDate}-&gt;{rate}<br>
&nbsp; if (YTD &gt;= $cap)<br>
&nbsp; &nbsp; return 0<br>
&nbsp; else<br>
&nbsp; {<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; fica = rate * gross<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; if (fica + YTD &lt;= cap)<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return fica<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; else<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp; return (cap - YTD)&nbsp;
* rate<br>
&nbsp; &nbsp;}<br>
}<br>
<br>
<table cellpadding="2" cellspacing="2" border="0" width="30%">
<tbody>
<tr>
<td valign="Top">data{$foundDate}-&gt;<br>
</td>
<td valign="Top">{rate}<br>
</td>
</tr>
<tr>
<td valign="Top">ex. data{20010101}-&gt;<br>
</td>
<td valign="Top">{cap}<br>
</td>
</tr>
</tbody>
</table>
<br>
sub new()<br>
{<br>
&nbsp; &nbsp; #create tables for lookup<br>
&nbsp; data{<br>
&nbsp; &nbsp; '19990101' =&gt; {rate =&gt; 0.0565, cap =&gt; 68000},<br>
&nbsp; &nbsp; '20010101' =&gt; {rate =&gt; 0.0565, cap =&gt; 72000}<br>
&nbsp; } &nbsp; &nbsp;<br>
}<br>
</body>
</html>