sir patulong nman po about turbo c programming using array
eto po ung sample output
[1] add employee
[2] delete employee
[3] view report
[4] sort employee
[5] exit
----------------------------------------------------
(add employee)
enter employee number:
enter employee name:
enter salary rate:
enter number of days work:
enter another(y/n):
----------------------------------------------------
(delete employee)
enter employee number to delete:
(else kung hindi naeexist ung employee number ipiprint nya is
"EMPLOYEE DOES NOT EXIST")
---------------------------------------------------
(view report)
epm number-emp name-days of work-income- tax -total income
1001 - jonathan- 5 -2000.00- 200.00-1800.00
550 - mark - 5 -1000.00- 100.00-900.00
TOTAL =3000.00=300.00=2700.00
(salary rate nung mark is 200)
---------------------------------------------------
(sort employee)
empoloyee number ung isosort nya una ung mababa tpos mataas
example:
eployee number
500 (then ung mga info nya)
1001 (then ung mga info nya)
--------------------------------------------------
(exit)
exit from the program
--------------------------------------------------
patulong naman po d2 as soon as posible sir
thank you in advance
e2 po sir pahelp naman po about sa delete and ung sa total plss...
# include <stdio.h>
# include <conio.h>
# include <stdlib.h>
# define s scanf
# define p printf
# define max 10
void add (void);
void del (void);
void view (void);
void sort (void);
int empnum [max];
char *empname[10] [max];
float empsal [max];
int empdw [max];
int ctr=0;
int gi,ni,wt;
main()
{
int choice;
clrscr();
p("\tPAYROLL SYSTEM");
p("\n\n MAIN MENU");
p("\n\n[1] ADD EMPLOYEE ");
p("\n[2] DELETE EMPLOYEE");
p("\n[3] VIEW REPORT");
p("\n[4] SORT EMPLOYEE");
p("\n[5] QUIT");
p("\n\n What do you want to do : ");
s("%d",&choice);
switch(choice)
{
case 1: add(); break;
case 2: del(); break;
case 3: view(); break;
case 4: sort(); break;
case 5: exit(choice==5); break;
default:
p("\n\tInvalid Choice!");
p("\n\nPress any key to continue ... ");
{
getch();
main();
}
}
getch();
return 0;
}
void add()
{
int i;
char ans;
for(i=ctr; i< max && ans !='n' && ans != 'N' ; i++)
{
clrscr();
p(" Enter Employee Number: ");
s("%d",&empnum);
ctr++;
p(" Enter Employee Name: ");
s("%s",&empname);
p(" Enter Salary Rate: ");
s("%f",&empsal);
p(" Enter No. of Day(s) Work: ");
s("%d",&empdw);
p(" Enter Another (y/n): ");
ans = getch();
empsal=empsal*empdw;
}
main();
}
void view()
{
int i,c,r;
float tax,net,gi;
clrscr();
gotoxy(22,2);
p("-----------------------------------------");
gotoxy(22,3);
p("| PAYROLL SYSTEM |");
gotoxy(22,4);
p("-----------------------------------------");
gotoxy(1,6);
p("|----------------------------------------------------------------------|");
gotoxy(1,7);
p("| Emp. No | Emp. Name | NDW | Gr. Inc. | W/Tax | Net Inc |");
gotoxy(1,8);
p("|----------------------------------------------------------------------|");
for (i=0;i<ctr;i++)
{
tax=empsal*0.10;
net=empsal-tax;
p("\n| %3d %3s %3d %.2f %.2f %.2f | ",empnum,empname,empdw,empsal,tax,net);
// p("\n|----------------------------------------------------------------------|");
} // for(c= 1;c<=i;c++)
//{
// gi=0;
// for(r=empsal;r<=empsal;r++);
// {
// gi=r+empsal;
// }
// }
p("\n| TOTAL %.2f | ", gi);
p("\n|----------------------------------------------------------------------|");
p("\n\n Press any key to return to main menu ... ");
getch();
main();
}
void del()
{
int delit,temp,i;
int ctr=max;
clrscr();
for (i=0;i<ctr;i++)
{
gotoxy(10,3);
p(" Enter Employee Number to Delete: ");
s("%d",&delit);
for(i=0;i<ctr;i++)
{
temp=empnum;
if(empnum==delit)
{
empnum=empnum[i+1];
empnum[i+1]=temp;
}
else
{
empnum=temp;
}
}
}
ctr--;
main();
}
void sort()
{
int i,j,temp;
for(j=0; j<ctr; j++)
{
for(i=0; i<ctr-1; i++)
{
if (empnum > empnum[i+1])
{
temp= empnum;
empnum=empnum[i+1];
empnum[i+1]=temp;
}
}
}
view();
}
eto po ung sample output
[1] add employee
[2] delete employee
[3] view report
[4] sort employee
[5] exit
----------------------------------------------------
(add employee)
enter employee number:
enter employee name:
enter salary rate:
enter number of days work:
enter another(y/n):
----------------------------------------------------
(delete employee)
enter employee number to delete:
(else kung hindi naeexist ung employee number ipiprint nya is
"EMPLOYEE DOES NOT EXIST")
---------------------------------------------------
(view report)
epm number-emp name-days of work-income- tax -total income
1001 - jonathan- 5 -2000.00- 200.00-1800.00
550 - mark - 5 -1000.00- 100.00-900.00
TOTAL =3000.00=300.00=2700.00
(salary rate nung mark is 200)
---------------------------------------------------
(sort employee)
empoloyee number ung isosort nya una ung mababa tpos mataas
example:
eployee number
500 (then ung mga info nya)
1001 (then ung mga info nya)
--------------------------------------------------
(exit)
exit from the program
--------------------------------------------------
patulong naman po d2 as soon as posible sir
thank you in advance
e2 po sir pahelp naman po about sa delete and ung sa total plss...
# include <stdio.h>
# include <conio.h>
# include <stdlib.h>
# define s scanf
# define p printf
# define max 10
void add (void);
void del (void);
void view (void);
void sort (void);
int empnum [max];
char *empname[10] [max];
float empsal [max];
int empdw [max];
int ctr=0;
int gi,ni,wt;
main()
{
int choice;
clrscr();
p("\tPAYROLL SYSTEM");
p("\n\n MAIN MENU");
p("\n\n[1] ADD EMPLOYEE ");
p("\n[2] DELETE EMPLOYEE");
p("\n[3] VIEW REPORT");
p("\n[4] SORT EMPLOYEE");
p("\n[5] QUIT");
p("\n\n What do you want to do : ");
s("%d",&choice);
switch(choice)
{
case 1: add(); break;
case 2: del(); break;
case 3: view(); break;
case 4: sort(); break;
case 5: exit(choice==5); break;
default:
p("\n\tInvalid Choice!");
p("\n\nPress any key to continue ... ");
{
getch();
main();
}
}
getch();
return 0;
}
void add()
{
int i;
char ans;
for(i=ctr; i< max && ans !='n' && ans != 'N' ; i++)
{
clrscr();
p(" Enter Employee Number: ");
s("%d",&empnum);
ctr++;
p(" Enter Employee Name: ");
s("%s",&empname);
p(" Enter Salary Rate: ");
s("%f",&empsal);
p(" Enter No. of Day(s) Work: ");
s("%d",&empdw);
p(" Enter Another (y/n): ");
ans = getch();
empsal=empsal*empdw;
}
main();
}
void view()
{
int i,c,r;
float tax,net,gi;
clrscr();
gotoxy(22,2);
p("-----------------------------------------");
gotoxy(22,3);
p("| PAYROLL SYSTEM |");
gotoxy(22,4);
p("-----------------------------------------");
gotoxy(1,6);
p("|----------------------------------------------------------------------|");
gotoxy(1,7);
p("| Emp. No | Emp. Name | NDW | Gr. Inc. | W/Tax | Net Inc |");
gotoxy(1,8);
p("|----------------------------------------------------------------------|");
for (i=0;i<ctr;i++)
{
tax=empsal*0.10;
net=empsal-tax;
p("\n| %3d %3s %3d %.2f %.2f %.2f | ",empnum,empname,empdw,empsal,tax,net);
// p("\n|----------------------------------------------------------------------|");
} // for(c= 1;c<=i;c++)
//{
// gi=0;
// for(r=empsal;r<=empsal;r++);
// {
// gi=r+empsal;
// }
// }
p("\n| TOTAL %.2f | ", gi);
p("\n|----------------------------------------------------------------------|");
p("\n\n Press any key to return to main menu ... ");
getch();
main();
}
void del()
{
int delit,temp,i;
int ctr=max;
clrscr();
for (i=0;i<ctr;i++)
{
gotoxy(10,3);
p(" Enter Employee Number to Delete: ");
s("%d",&delit);
for(i=0;i<ctr;i++)
{
temp=empnum;
if(empnum==delit)
{
empnum=empnum[i+1];
empnum[i+1]=temp;
}
else
{
empnum=temp;
}
}
}
ctr--;
main();
}
void sort()
{
int i,j,temp;
for(j=0; j<ctr; j++)
{
for(i=0; i<ctr-1; i++)
{
if (empnum > empnum[i+1])
{
temp= empnum;
empnum=empnum[i+1];
empnum[i+1]=temp;
}
}
}
view();
}
Last edited: