19.12.2012 Views

Computer Programming Concepts and Visual Basic David I. Schneider

Computer Programming Concepts and Visual Basic David I. Schneider

Computer Programming Concepts and Visual Basic David I. Schneider

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Private Function TaxMarried(adjPay As Single) As Single<br />

‘Task 6.3: Compute federal tax for married person based on adjusted pay<br />

Select Case adjPay<br />

Case 0 To 124<br />

TaxMarried = 0<br />

Case 124 To 899<br />

TaxMarried = 0.15 * (adjPay - 124)<br />

Case 899 To 1855<br />

TaxMarried = 116.25 + 0.28 * (adjPay - 899)<br />

Case 1855 To 3084<br />

TaxMarried = 383.93 + 0.31 * (adjPay - 1855)<br />

Case 3084 To 5439<br />

TaxMarried = 764.92 + 0.36 * (adjPay - 3084)<br />

Case Is > 5439<br />

TaxMarried = 1612.72 + 0.396 * (adjPay - 5439)<br />

End Select<br />

End Function<br />

Private Function TaxSingle(adjPay As Single) As Single<br />

‘Task 6.2: Compute federal tax for single person based on adjusted pay<br />

Select Case adjPay<br />

Case 0 To 51<br />

TaxSingle = 0<br />

Case 51 To 517<br />

TaxSingle = 0.15 * (adjPay - 51)<br />

Case 517 To 1105<br />

TaxSingle = 69.6 + 0.28 * (adjPay - 517)<br />

Case 1105 To 2493<br />

TaxSingle = 234.54 + 0.31 * (adjPay - 1105)<br />

Case 2493 To 5385<br />

TaxSingle = 664.82 + 0.36 * (adjPay - 2493)<br />

Case Is > 5385<br />

TaxSingle = 1705.94 + 0.396 * (adjPay - 5385)<br />

End Select<br />

End Function<br />

Private Function Total_Pay(prevPay As Single, pay As Single)<br />

‘Compute total pay before taxes<br />

Total_Pay = prevPay + pay<br />

End Function<br />

COMMENTS<br />

A Case Study: Weekly Payroll 125<br />

1. In the function FICA_Tax, care has been taken to avoid computing Social Security<br />

benefits tax on income in excess of $68,400 per year. The logic of the program<br />

makes sure an employee whose income crosses the $68,400 threshold<br />

during a given week is taxed only on the difference between $68,400 <strong>and</strong> his<br />

previous year-to-date income.<br />

2. The two functions TaxMarried <strong>and</strong> TaxSingle use Select Case to incorporate the<br />

tax brackets given in Tables 4.4 <strong>and</strong> 4.5 for the amount of federal income tax<br />

withheld. The upper limit of each Case clause is the same as the lower limit of<br />

the next Case clause. This ensures fractional values for adjPay, such as 51.50 in

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!