Write a program to process weekly employee time cards for al
Write a program to process weekly employee time cards for all employees of an organization. Each employee will have three data items: an identification number, the hourly wage rate, and the number of hours worked during a given week. Each employee is to be paid time and a half for all hours worked over 40. A tax amount of 3.625% of gross salary will be deducted. The program output should show the employee’s number and net pay. Display the total payroll and the average amount paid at the end of the run.
Please do this code in the language C
Solution
/* program to process weekly employee time cards for all employees of an organization*/
#include <stdio.h>
//structure is used to manage 3 dataparts of all employees in organization
struct emp {
char empid[50];
int wagerate;
int workhours;
} empdata[100];
int main()
{
int num,i,payment,overtime,sum=0; //varible declarations
float avg;
struct emp empdata[100];
printf(\"Enter Number of Employees in Organization\ \"); //prompt for asking number of employees
scanf(\"%d\",&num); //read number of employees
for(i=1;i<=num;i++) //using loop take data of all employees
{
printf(\"Enter ID\ \");
scanf(\"%s\",empdata[i].empid); //read employee id
printf(\"Enter Hourly wage Rate for %s \ \",empdata[i].empid);
scanf(\"%d\",&empdata[i].wagerate); //read employee wagerate
printf(\"Enter Number Hours worked per week by %s \ \",empdata[i].empid);
scanf(\"%d\",&empdata[i].workhours); //read employee work hours
//printf(\"\ %d\\t%d\\t\",empdata[i].wagerate,empdata[i].workhours);
}
for(i=1;i<=num;i++) //loop to generate outputs for all employees
{
printf(\"\ Processing Payrolls .....\ \");
if (empdata[i].workhours>40) //check employee done overtime then calculate payment
{
overtime=empdata[i].workhours-40;
payment=(overtime)*((empdata[i].wagerate)/2)+(empdata[i].workhours)*(empdata[i].wagerate); //calculate payment for employee id if workhours >40
sum=sum+payment;
}
else
{
payment=(empdata[i].workhours)*(empdata[i].wagerate); //calculate payment for employee id if workhours <40
sum=sum+payment;
}
printf(\"ID %s\\t - \\t Payment is \\t%d\ \",empdata[i].empid,payment); //display employee id and net payement
}
printf(\"Total payroll %d \ \",sum); //display final pay raoll amount
avg=sum/num;
printf(\"Average amount paid per employee %f \ \",avg); //display average payment per employee
return 0;
}
Note : enter less number of employess to enter less input .
Output :
1111
Enter Hourly wage Rate for 1111
100
Enter Number Hours worked per week by 1111
10
Enter ID
2222
Enter Hourly wage Rate for 2222
200
Enter Number Hours worked per week by 2222
10
Processing Payrolls .....
ID 1111 - Payment is 1000
Processing Payrolls .....
ID 2222 - Payment is 2000
Total payroll 3000
Average amount paid per employee 1500.000000

