CPSC 120 Assignment 6 Back to Assignment index page
Instructor: Brenneman  
   
Due Date: midnight, Mon, Nov 19  

Exception Handler, Procedures, Functions, Records, Arrays

Description:  Payroll Program

This program will calculate the gross pay and net pay for 10 employees who work at the Ada Programming Factory.   The user will be prompted to enter, the name, rate of pay, and number of hours worked for the week.  This should be implemented in a procedure (payroll_input) that includes exception handling.  So, if the user makes an error in the input, he/she should be asked to try again. 

Your data would best be handled by creating a record to hold employee data, and creating an array of 10 of those records. Implement your data structures in such a way that you could change your program to handle more employees by changing only one number in your program.

The program will calculate the gross pay and net pay by using:

gross pay = (hours worked) x rate,  (for the hours worked <= 40)
  + (hours worked) x rate x 1.5, (for the hours worked > 40)
   
net pay = gross pay x 0.9, (for the first $200 of the gross pay, only 10% deducted)
  + (for grosspay>200) x 0.8, (20% deducted for all $ earned above $200)
  (i.e, 10% of the first $200 is deducted, and 20% is deducted from the amount above $200.)

The user must be prompted for the input, for example:

Program Outputs Enter the name for employee #1:
User Inputs Mary Smith
Program Outputs Enter the rate of pay:
User Inputs 7.25
Program Outputs Enter the number of hours worked:
User Inputs 42
Program Outputs Enter the name for employee #1:
User Inputs Miss Piggy
Program Outputs Enter the rate of pay:
  and so on for 10 employees. Hint, might want to make an input file and redirect it.
Program Outputs

Mary Smith
Hours Worked --    
42
Gross Pay    --   $311.75
Withholding  --   $ 42.35
Net Pay      --   $269.40

Miss Piggy
Hours Worked --     31
Gross Pay    --   $271.45
Withholding  --  

and so on for all 10 employees.

You must implement the prompting for data and the input of data in a procedure named payroll_input.  In addition, the calculation of gross pay must be performed in a function or procedure and the calculation of net pay must be performed in a function or procedure.

The program must be in a file named program6.adb.  Use the submit command to turn in your program for grading.  Example, submit cpsc120-01 program6.adb, remember to use the section number for your class.   Please compile and run your program immediately before submitting it.  Never make a change to the code file(s) and turn it in without compiling and running it first.  It is very easy to make a last minute mistake that introduces syntax errors, so checking before submitting can save you an unnecessary grade of 0.  You may submit as many times as you like, but only the last submission is kept.  Since only the last submission is kept, if the last one is late, then your assignment is late and will recieve an automatic grade of zero (0).


A brief pseudocode outline of what your main program could look like:

for i in 1..numemployees loop-- loop to input stuff into employee array, read all data first
      payroll_input(employee)
endloop

for i in 1..numemployees loop -- loop to calculate and output
      calculate pay and output stuff in lots of put statements

endloop