Monday, October 17, 2011

Payroll Programs with Overtime

About Overtime
Florida law requires that certain workers earning more than minimum wage be paid 1.5 times their normal wage (called "time and a half") for any hours in excess of 40 hours in one week. Florida does not have a daily limit. Here are a few weekly pay calculations for workers earning $10/hr and qualifying for time and a half:

Worker 1
: Works 32 hours at $10/hr. No overtime applies because hours do not exceed 40.
Regular pay = 32 * 10 = $320.00.
Overtime pay = $0.00.
Total pay = $320.00.

Worker 2: Works 44 hours at $10/hr. This worker qualifies for 4 hours (44 - 40) of overtime pay.
Regular pay = 40 * 10 = $400.00.
Overtime pay = (44 - 40) * 10 * 1.5 = $60.00.
Total pay = $460.00.

Worker 3: Works 50 hours at $10/hr. This worker qualifies for 10 hours (50 - 40) of overtime pay.
Regular pay = 40 * 10 = $400.00.
Overtime pay = (50 - 40) * 10 * 1.5 = $150.00.
Total pay = $550.00.

RAPTOR Payroll Program
A payroll program should begin by prompting a user for the weekly hours worked. A selection structure (also known as an if structure) then uses a simple conditional expression to detect whether or not an overtime situation exists. The "branches" of the selection are then coded as follows:

If overtime doesn't apply:
  • an assignment determines the regular pay as the product of the hourly rate and the weekly hours.
  • overtime pay is set to the value zero in another assignment.
If overtime does apply:
  • an assignment determines the regular pay by multiplying the hourly rate * 40.
  • overtime pay is assigned by multiplying the hours in excess of 40 * hourly rate * 1.5.
After the selection structure, the program continues by assigning total weekly pay as the sum of the regular pay plus overtime pay. Finally, the program would finish by outputting a "pay report" that details the weekly hours, regular pay, overtime pay, and total pay.

The concepts in this post should help with your RAPTOR 3 assignment.