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 ');
  readln(10);
  sum:= 0;
    for employee:= 1 to 10 do
  begin
    write('Enter name of employee ');
    readln(name);
    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 ');
     readln(age);
   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.
kazooie21Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

kazooie21Author Commented:
I need an answer ASAP! It's EXTREMELY urgent!!
0
scrapdogCommented:
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
BatalfCommented:
Hopefully, this would help you :

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 ');
  readln(10);
  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 ');
    readln(employee[i].name);
    write('Enter age of ',employee[i].name);
    readln(employee[i].age);
    write('Enter rate of pay ');
    readln(employee[i].rate);
    write('Enter no. of hours worked ');
    readln(employee[i].hours);
    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 ');
     readln(age);
   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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Pascal

From novice to tech pro — start learning today.