In the previous module, you wrote a simple RAPTOR program to let you input one employee's data and compute some basic payroll information. Now, expand on that program. Using RAPTOR, make use of its built-in SELECTION and LOOP structures to let you flowchart the program and then run it.

The second part of your payroll program (withholding) will help a small business compute its weekly payroll, print out the information for each paycheck, and keep running totals on gross payroll, as well as various withholding funds such as taxes, social security, and pension.

Spiral Development Plan

This Payroll Program with Withholding will help a small business compute its weekly payroll, print out the information for each paycheck, and keep running totals on gross payroll as well as various withholding funds - taxes, social security, and pension.

In order to do that, it will have to create some variables for those cumulative or running sums, and each time it inputs, computes and outputs an individual employee's paycheck, it will need to add those values to these accumulator variables.

The wage rates, tax rates, wages, etc., are all in a currency of your choice - just be consistent with the symbol you use, the prompts you give the user, etc. But all computations, inputs, and outputs will be in that base currency. No "currency exchange" needed here!

"What kind of numbers?" For a start, use floating point numbers (reals).

Design Considerations

Chapter two introduces the concept of a module as a stretch of code that you name, define its work, and then CALL it to use it when you need to. You may find this module approach makes designing the program easier. Even without it, you'll see that:

There is an "outer" flow (input the company-wide payroll rate information; initialize variables; etc.), then there's a loop that:

  • prompts for an employee ID number, and if positive it:
    • prompts for all the paycheck data,
    • computes the paycheck,
    • writes that employee's paycheck (outputs the data, and)
    • adds that employee's gross wages, tax withheld, social security and pension withholding amounts to their respective accumulators;
  • and when there are no more employees to write checks for, it prints a report that says how many employees it wrote checks for, the total amounts of the gross pay and withholding amounts,
  • and then stops.

The lazy/efficient programmer might study that indented bullet list, convince themselves as to whether it is or is not a correct way to do this program, and use it as a start on a pseudocode design for the program!

But, we're doing this in RAPTOR pseudocode is optional, and if it helps you see what you have to do, then youre welcome to use it!

Program Requirements:

Input data:

  • For each employee, their name, ID number, hourly wage rate, number of hours worked, and the percentage of gross wages that they contribute to their pension plan each pay period.
  • For all employees (input once at start of program), the income tax withholding rate, the Social Security tax withholding rate.

Output data:

  • For each employee, paycheck data consisting of name, ID number, wage rate, number of regular time hours worked, number of overtime hours worked (in excess of 40 hours), gross pay (including both regular pay for hours up to 40, and overtime at 1.5 times base pay rate for hours beyond 40 hours a week); income tax withheld (tax rate times gross pay); Social Security withheld (SS tax rate times gross pay); Contributions to Pension withheld (contribution rate times gross pay); Net pay (gross minus taxes and pension).
  • After last employee: output the running (cumulative) totals of the gross pay, income tax withheld, social security tax withheld, and pension contributions withheld.

Possible Error-Checking to Consider:

  • If you added up the three withholding amounts (tax, social security, pension), and subtracted that number from the gross payroll, should it equal the total of all of the net pay that was paid to the employees across all of the paychecks? Why or why not?
  • How should your program behave if the user puts in ridiculous values (such as an hourly wage rate of a million dollars and twelve cents)? Or a negative number for one of the withholding rates?
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.