C++
C++ Project on Payroll Management
C++ Project on Payroll Management
#include
#include
#include
#include
#include
#include
#include
#include
struct roll
{
char na[20], des[20];
int co;
float sal, tax, hra, gr, da, np;
} oll;
fstream pay;
char c;
int l;
char choice;
void dev()
{
clrscr();
for (int x = 50; x >= 20; x--)
{
textcolor(WHITE + LIGHTGRAY);
delay(160);
gotoxy(x, 12);
cputs(" P R O J E C T ");
gotoxy(x, 14);
cputs(" D E V E L O P E D B Y : ");
gotoxy(x, 16);
cputs("Navi");
}
gotoxy(x, 24);
cputs("PRESS ANY KEY TO CONTINUE");
getch();
}
void main()
{
clrscr();
dev();
int gdriver = DETECT, gmode, errorcode;
initgraph(&gdriver, &gmode, "c:\\tc\\bgi");
errorcode = graphresult();
if (errorcode != grOk)
{
cout << "Graphics error: " << grapherrormsg(errorcode);
cout << "\nPress any key to halt:";
getch();
exit(1);
}
do
{
clrscr();
cout << "\n1. ADD RECORD";
cout << "\n2. DISPLAY RECORD";
cout << "\n3. SEARCH RECORD";
cout << "\n4. EXIT";
cout << "\nENTER YOUR CHOICE:";
cin >> choice;
switch (choice)
{
case '1':
pay.open("oll.dat", ios::out | ios::app);
do
{
clrscr();
cout << "\n EMPLOYEE NAME:";
cin >> oll.na;
cout << "\n EMPLOYEE CODE";
cin >> oll.co;
cout << "\n EMPLOYEE DESIGNATION:";
int ch;
cout << "\n1.SUBSTAFF";
cout << "\n2.CLERK";
cout << "\n3.MANAGER";
cout << "\n ENTER YOUR CHOICE:(1/2/3)";
cin >> ch;
switch (ch)
{
case 1:
oll.sal = 1000;
oll.hra = 100;
oll.da = oll.sal * 1.10;
oll.tax = 2 * (oll.sal) / 100.0;
strcpy(oll.des, "SUBSTAFF");
break;
case 2:
oll.sal = 2000;
oll.hra = 200;
oll.da = 200;
oll.tax = 10 * (oll.sal) / 100.0;
strcpy(oll.des, "CLERK");
break;
case 3:
oll.sal = 14000;
oll.hra = 400;
oll.da = 400;
oll.tax = 20 * (oll.sal) / 100.0;
strcpy(oll.des, "MANAGER");
break;
default:
cout << "\n INPUT IS INVALID";
break;
}
oll.gr = oll.sal + oll.hra + oll.da;
oll.np = oll.gr - oll.tax;
pay.write((char*)&oll, sizeof(oll));
cout << "\n TO CONTINUE ADDING DATA(Y/N):";
cin >> c;
} while ((c == 'Y') || (c == 'y'));
pay.close();
break;
case '2':
pay.open("oll.dat", ios::in);
if (!pay)
{
cout << "\n\nFile Not Found...\nProgram Terminated!";
exit(0);
}
pay.seekg(0);
while (!pay.eof())
{
pay.read((char*)&oll, sizeof(oll));
if (!pay.eof())
{
cout << "\n*********************************************";
cout << "\n SUSHMA ENTERPRISES ";
cout << "\n*********************************************";
cout << "\nEMPLOYEE NAME :" << oll.na;
cout << "\nEMPLOYEE CODE :" << oll.co;
cout << "\nEMPLOYEE DESIGNATION :" << oll.des;
cout << "\nBASIC SALARY :" << oll.sal;
cout << "\nHRA :" << oll.hra;
cout << "\nDA :" << oll.da;
cout << "\nGROSS SALARY :" << oll.gr;
cout << "\nTAX DEDUCTED :" << oll.tax;
cout << "\nNET PAY :" << oll.np;
}
}
pay.close();
break;
case '3':
int eno;
cout << "\nENTER EMPLOYEE CODE TO SEARCH:";
cin >> eno;
pay.open("oll.dat", ios::in);
if (!pay)
{
cout << "\n\nFile Not Found...\nProgram Terminated!";
exit(0);
}
pay.seekg(0);
while (!pay.eof())
{
pay.read((char*)&oll, sizeof(oll));
if (!pay.eof())
{
if (oll.co == eno)
{
cout << "\n*********************************************";
cout << "\n SUSHMA ENTERPRISES ";
cout << "\n*********************************************";
cout << "\nEMPLOYEE CODE :" << oll.co;
cout << "\nEMPLOYEE NAME :" << oll.na;
cout << "\nEMPLOYEE DESIGNATION :" << oll.des;
cout << "\nBASIC SALARY :" << oll.sal;
cout << "\nHRA :" << oll.hra;
cout << "\nDA :" << oll.da;
cout << "\nGROSS SALARY :" << oll.gr;
cout << "\nTAX DEDUCTED :" << oll.tax;
cout << "\nNET PAY :" << oll.np;
}
}
}
pay.close();
break;
case '4':
exit(0);
}
} while (choice != 4);
closegraph();
}