You are on page 1of 4

#include<stdio.

h>
#include<conio.h>

char post[3][30] = {"Manager", "Supervisor", "Employee"};


int i,f,p,num, id;
struct employee {
char name[32];
int pos,hw,gross,id;
float tax,sss,med,ded,net;

};
void add_emp(struct employee e1[])
{
clrscr();

num++;
i = num-1;
printf("\nEnter ID:");
scanf("%d",&e1[i].id);
printf("\nEnter name:");
scanf("%s",&e1[i].name);
printf("\n[1] Manager [2] Supervisor [3] Employee");
printf("\nEnter position:");
scanf("%d",&e1[i].pos);

switch(e1[i].pos)
{
case 1:

{
printf("\n\n Rate: P500.00");
printf("\n\n No.of hours worked:");
scanf("%d",&e1[i].hw);
e1[i].gross=e1[i].hw*500;
printf("\n Gross: %d",e1[i].gross);
printf("\nDEDUCTIONS:");
e1[i].med=100;
printf("\n\tMedical: %0.2f",e1[i].med);
e1[i].sss=e1[i].gross*0.1;
printf("\n\tSSS: %0.2f",e1[i].sss);
e1[i].tax=e1[i].gross*0.15;
printf("\n\tTAX: %0.2f",e1[i].tax);
e1[i].ded=e1[i].med+e1[i].sss+e1[i].tax;
printf("\n\tTotal Deduction: %0.2f",e1[i].ded);
e1[i].net=e1[i].gross-e1[i].ded;
break;
}

case 2:

{
printf("\n\n Rate: P400.00");
printf("\n\n No. of hours worked:");
scanf("%d",&e1[i].hw);
e1[i].gross=e1[i].hw*400;
printf("\n Gross: %d",e1[i].gross);
printf("\nDEDUCTIONS:");
e1[i].med=100;
printf("\n\tMedical: %0.2f",e1[i].med);
e1[i].sss=e1[i].gross*0.1;
printf("\n\tSSS: %0.2f",e1[i].sss);
e1[i].tax=e1[i].gross*0.15;
printf("\n\tTAX: %0.2f",e1[i].tax);
e1[i].ded=e1[i].med+e1[i].sss+e1[i].tax;
printf("\n\tTotal Deduction: %0.2f",e1[i].ded);
e1[i].net=e1[i].gross-e1[i].ded;
break;
}

case 3:
{
printf("\n\n Rate:P300.00");
printf("\n\n No.of hours worked:");
scanf("%d",&e1[i].hw);
e1[i].gross=e1[i].hw*300;
printf("\n Gross: %d",e1[i].gross);
printf("\nDEDUCTIONS:");
e1[i].med=100;
printf("\n\tMedical: %0.2f",e1[i].med);
e1[i].sss=e1[i].gross*0.1;
printf("\n\tSSS: %0.2f",e1[i].sss);
e1[i].tax=e1[i].gross*0.15;
printf("\n\tTAX: %0.2f",e1[i].tax);
e1[i].ded=e1[i].med+e1[i].sss+e1[i].tax;
printf("\n\tTotal Deduction: %0.2f",e1[i].ded);
e1[i].net=e1[i].gross-e1[i].ded;
break;
}

default:
{
printf("\n Invalid");
}
}
getch();
}

void menu(struct employee e1[])


{
clrscr();
printf("MAIN MENU");
printf("\n[1] Create New Employee Record");
printf("\n[2] Print Payslip");
printf("\n[3] Search Employee ID");
printf("\n[4] Exit");
printf("\n\nEnter your choice: ");
scanf("%d",&f);
switch(f)
{
case 1:
{
clrscr();
add_emp(e1);
break;
}

case 2:
{
clrscr();
for (i = 0; i < num; i++) {
printf("\nName : %s \nID number: %d \nPosition: %s \nNo. of hours
worked: %d \n\tDEDUCTION: \n\tMedical: %0.2f \n\tSSS: %0.2f \n\tTAX: %0.2f \nTotal
Deductions: %0.2f \n\nNET INCOME: %0.2f",e1[i].name, e1[i].id, post[e1[i].pos-1],
e1[i].hw, e1[i].med, e1[i].sss, e1[i].tax, e1[i].ded, e1[i].net); }
break;
}

case 3:
clrscr();
printf("\nEnter Employee ID to be searched: ");
scanf("%d", &id);
int flag;
flag = 0;
for ( i = 0; i < num; i++) {
if ( id == e1[i].id)
{
printf("\nName : %s \nID number: %d \nPosition: %s \nNo. of
hours worked: %d \n\tDEDUCTION: \n\tMedical: %0.2f \n\tSSS: %0.2f \n\tTAX: %0.2f
\nTotal Deductions: %0.2f \n\nNET INCOME: %0.2f",e1[i].name, e1[i].id,
post[e1[i].pos-1], e1[i].hw, e1[i].med, e1[i].sss, e1[i].tax, e1[i].ded,
e1[i].net);
flag = 1;
} }
if (!flag) {

printf("NO RECORD FOUND"); }


break;

case 4:
printf("\nPress any key to exit...");
getch();
return 0;

default:
{
getch();
}
}
getch();
}

void main()
{
struct employee *e1;
clrscr();
do
{
menu(e1);
printf("\nDo you want to continue:(1/2)");
scanf("%d", &p);
}
while (p== 1);
if (!p)
{
printf("Press any key to exit...");
getch();
}
getch();
}

You might also like