# program for a payroll

I need a program that will print the payroll for a company. It's for an assignment. It should read the employee's name, hours worked, base rate of pay, and age.  Their gross wage is computer at regular rate for the first 40 hours and 1.5 times rate for hours over 40. Tax is witheld: 10% on first \$200 and 20% on anything over that. The first part of the printout should print this info. The second part should state the average gross pay for employees at least 55 yrs old, gross pay for employees over 55, name and gross pay for employee with largest gross(assume there's not a tie). I don't know how to do the second part, but I think I got a start on the first part: as follows.

program payroll
uses printer;
var name: string;
hours, age: integer
tax, rate, gross pay, net pay: real

begin
write('Enter number of employees ');
sum:= 0;
for employee:= 1 to 10 do
begin
write('Enter name of employee ');
write('Enter hours worked and rate ');
if hours > 40 then
gross pay:= (hours - 40) * (rate * 1.5)
end
else gross pay:= hours * rate
write('Enter age of employee ');
write('Enter tax ');
if gross pay > 200 then
tax:= (gross pay - 200) * 0.20 + 0.10 + gross pay
end
else tax:= gross pay * 0.10
write('Enter net pay ');
net:= gross pay - tax
end.
###### Who is Participating?

Commented:

You should absolutely use an array as I have done here :

program payroll
uses printer;

TYPE
employetype  = RECORD
name : string;
hours : integer;
age : integer;
grosspay : real;
rate : real;
netpay : real;
end;
var
employee : array[1..10] of employetype;
hours, age: integer
tax, rate, grosspay, netpay: real
I : integer;
average : real;
no,no2 : integer;
average2 : real;

name2 : string;
gross2 : real;
max : real;

begin
write('Enter number of employees ');
sum:= 0;
(* This part is for reading in the data for the employees*)
for i:= 1 to 10 do
begin
write('Enter name of employee ');
write('Enter age of ',employee[i].name);
write('Enter rate of pay ');
write('Enter no. of hours worked ');
if employee[i].hours > 40 then
begin
employee[i].grosspay:= (employee[i].hours - 40) * (employee[i].rate * 1.5);
employee[i].grosspay:=employee[i].grosspay + 40 * (employee[i].rate * 1.5);
end
else employee[i].grosspay:= employee[i].hours * employee[i].rate ;
(*   write('Enter age of employee ');
write('Enter tax '); *)

if employee[i].grosspay > 200 then
employee[i].tax:= (employee[i].grosspay - 200) * 0.20 + (0.10 * employee[i].grosspay);
else employee[i].tax:= employee[i].grosspay * 0.10
employee[i].netpay:= employee[i].grosspay - employee[i].tax
end;

(*This part for printing out all info *)

for i:=1 to 10 do
begin
writeln('Name : ',employee[i].name);
writeln('Age :  ',employee[i].age);
writeln('Gross pay : 'employee[i].grosspay);
writeln('Tax  : ',employee[i].tax);
writeln('Net pay : ',employee[i].netpay);
writeln('------------------------------------------------');
end;

(*The part for employee below 55 years old*)
average :=0;
no:=0;no2:=0;max:=0;
for i:=1 to 10 do
begin
if employee[i].age<55 then
begin
average:=average+employee[i].grosspay;
inc(no);
end
else
begin
average2 := average + employee[i].grosspay;
inc(no2);
end;
if employee[i].grosspay>max then
begin
name2 := employee[i].name;
gross2 := employee[i].grosspay;
end;

end;
average:=average/no;
average2:=average2/no2;

writeln('Average gross pay for employees (<55 years old) : ',average);
writeln('Average gross pay for employees older than 55 years : ',average2);
writeln('------------------------------------------------');
writeln('Largest grosspay :');
writeln('Name : ',name2);
writeln('Grosspay :',gross2);

end.
0

Author Commented:
I need an answer ASAP! It's EXTREMELY urgent!!
0

Commented:
since the values don't seem to be stored into an array, you are going to have to use accumulators

accumulators are just regular variables, but with a special purpose: they are added to, or keep a cumulative total

after each employee is input, add the value that was input to a running total, depending on what category they are in (test with the if statement)

when all of the employees are entered, just use the accumulators in any math operations you need to do (such as an average)
0