project payslip 2016~vishal.d

36

Upload: vishal-krishna

Post on 15-Apr-2016

230 views

Category:

Documents


0 download

DESCRIPTION

this about c++ programming though data file handling which clears clear concepts about classes through program.

TRANSCRIPT

Page 1: Project PaySlip 2016~vishal.d
Page 2: Project PaySlip 2016~vishal.d

TABLE OF CONTENT

Sl.No Contents Page

Number

1. Certificate 3

2. Acknowledgment 4

3. Project Introduction 5

4. Hardware Software Requirement 6

5. Introduction of C++ and Features of OOP 7

6. Data Structure used in Project 9

7. Project Coding 10

8. Input /Output Screen shots 26

9. Conclusion 29

10. Bibliography 30

P a g e | 2

Page 3: Project PaySlip 2016~vishal.d

Certificate The Project titled as ____________________________ is bonafied work of Master /Miss _____________________ Roll No:_________ of class ________ Sec __________ The Project coding entered in this journal have been satisfactorily completed

P a g e | 3

/Gadag Road, Hubballi गदग रोड , हुबल

KENDRIYA VIDYALAYA NO. 2, HUBBALLI

कीय ि�वालय मांक 2 , हबली

PRINCIPAL METRE S.T. Shri

_________ Date:

___________________ :meaN

External Examiner

_________________________

Date: _________

PGT CS

Deepak Gosain Examiner Internal

_________________________

PRINCIPAL

Page 4: Project PaySlip 2016~vishal.d

and submitted by Master/Miss ______________________ to fulfill the partial requirement of All India Senior Secondary Certificate Examination 2016 in the subject Computer Science.

A C K N O W L E D G E M E N T

In the beginning I was nervous as well as anxious to complete the

project and see the final output of the project. In this journey of project

development many people supported me in many ways to complete this

project.

I owe my earnest thanks to our worthy Principal Sir, Shri S.T.METRE

who permits me to work on this project and use the computer lab for

development purpose.

I bestow my heartfelt thanks to our Computer Science PGT, Shri

Deepak Gosain Singh Gosain, who helped and guided us at every step and

without his guidance and help this project would not be completed.

I also thank to my classmates who helped me while developing this

project and helped to debug it.

P a g e | 4

Page 5: Project PaySlip 2016~vishal.d

With all regards……

D. Vishal Class XII Science Board

Roll No……………………..

P R O J E C T I N T R O D U C T I O N

he primary aim of this project is to fulfill the partial requirement for

the AISSCE 2016 practical examination of Computer Science. TAfter learning C++ in class XI and XII, it is a great experience to

develop software in C++. It is really a joy to make project in C++ . My

project title is “Monthly Pay Automation System” that have following

features :

Create a database to store employee record and monthly

salary.

Add new employee record in the employee file.

Modify existing employee record the employee file.

Delete existing employee record.

Generate the monthly pay slip for each employee.

Generate all report of all employees

Generate department wise report of the employees.

Search the employee record on the basis of employee code.

The purpose behind this is to consolidate the concepts and practices

imparted during the course and to serve as a record of competence in

object oriented programming and to implement its key features.

P a g e | 5

Page 6: Project PaySlip 2016~vishal.d

This project includes all major key concepts that we have learned

through Computer Science course i.e. Binary File Handling, Classes and

Objects, Inheritance, and structure, function and reusability.

HARDWARE & SOFTWARE REQUIREMENT

(A) MINIMUM HARDWARE REQUIREMENT-

An Intel based central processing unit capable of running any sort of windows operating

system such as Pentium based workstation.

• Minimum 64 MB RAM (128 MB Desirable) at server.

• Minimum 60 MB of free disk space for files.

• A CD ROM drive

• Minimum 128 MB of RAM at workstation.

• VGA 15” color monitor for workstation.

(B) MINIMUM SOFTWARE REQUIREMENT-

The software requirements are as follows.

• Windows XP/ 7/ 8 or Above

• Turbo C++ 4.5 Editor is used for developing this project It is compiled at 32

bit windows mode.

• Microsoft Word 2010 is used for documentation purpose on Windows 8 OS

P a g e | 6

Page 7: Project PaySlip 2016~vishal.d

INTRODUCTION OF C++ AND FEATURES OF OOP

he C++ programming language was developed at AT&T Bell

Laboratories in the early 1980s by Bjarne Stroustrup. He found ‘c’

lacking for simulations and decided to extend the language by adding

features from his favourite language, Simula 67 was one of earliest

object-oriented language. Bjarne Stroustrup called it “C with Classes”

originally. The

Tname of C++ (pronounced C plus plus ) was coined by Rick Mascitti where “++” is the C

increment operator .Ever since its birth ,C++ evolved to cope with problems

encountered by users , and through discussions at AT&T . However, the maturation of

the C++ language was attested to by two events:

I. The formation of an ANSI ( American National Standard Institute) C++ committee.

II. The publication of The Annotated C++ Reference Manual by Ellis.

The major reason behind the success and popularity of C++ is that it supports

the object oriented technology, the latest in the software development and the most

near to the real world .

One can easily judge the judge the importance of C++ as given in the following

lines:

“Object Oriented Technology is regarded as the ultimate paradigm for the

modeling of information, be that data or logic. The C++ has by now shown to

fulfill this goal”.

OBJECT ORIENTED PROGRAMMNING:

OOP stands for Object Oriented Programming. In, Object-Oriented Programming

(OOP), the program is organized around the data being operated upon rather than the

operations performed. The basic idea behind OOP is to combine both, data and its

P a g e | 7

Page 8: Project PaySlip 2016~vishal.d

functions that operate on the data into a single unit called object. Following are the

basic OOP concepts:

1. Data Abstraction 2. Data Encapsulation 3. Modularity

4. Inheritance 5. Polymorphism

OOP provides the following advantages :

OOPs is closer to real world model.

Hierarchical relationship among objects can be well-represented through

inheritance.

Data can be made hidden or public as per the need. Only the necessary data is

exposed enhancing the data security.

Increased modularity adds ease to program development.

Private data is accessible only through designed interface in a way suited to the

program.

Following are the general OOP concepts: 1. Data Abstraction: Data abstraction means, providing only essential information to

the outside word and hiding their background details i.e. to represent the needed

information in program without presenting the details.

2. Data Encapsulation: The wrapping up of data and operations/functions (that

operate o the data) into a single unit (called class) is known as Encapsulation.

3. Modularity: Modularity is the property of a system that has been decomposed into a

set of cohesive and loosely coupled modules.

4. Inheritance: Inheritance is the capability of one class of things to inherit capabilities

or properties from another class.

5. Polymorphism: Polymorphism is the ability for a message or data to be processed in

more than one form.

DATA STRUCTURE USED IN PROJECT

Data Structure is a named group of data of different data types which can be

processed as a single unit. A data structure has well defined operations, behaviours and

properties.

P a g e | 8

Page 9: Project PaySlip 2016~vishal.d

In this project we have used following data structures:-

Primitive Data Types:- All fundamental data types such as char, int, float, double,

float and void are implemented in this project.

Non-Primitive Data Types :- Those data types which are composed of primitive data

types are called user-defined or non-primitive data type. In

this project uses array, structure, and class non-primitive

data type.

Pointer: A special data type pointer data type has been introduced by some

programming languages. The pointer data type enables

storage of pointers i.e. addresses of some other data location.

Pointer has great use in linked list, stack and queue.

Binary Files: One binary file database.dat is used in this project to store the data of the

employees, and their salary details.

Inheritance: Single inheritance between base class employee and sub class salary is

implemented in this project.

P R O J E C T C O D I N G

//C++ Program for creating pay slip of employees of a company

#include<iostream.h>

#include<conio.h>

#include<fstream.h>

#include<string.h>

#include<stdio.h>

#include<stdlib.h>

P a g e | 9

Page 10: Project PaySlip 2016~vishal.d

#include<iomanip.h>

#include<dos.h> // for system date

//global variable declaration int

k=7,r=0,flag=0;

struct Date {

int mm,dd,yy;

}SysDt;

void GetSysDate() // function to get system date

{

struct date ds; //date is declared in dos.h for system date

getdate(&ds);

cout<<" "<<ds.da_mon<<" - "<<ds.da_year;

}

ofstream fout; ifstream

fin;

class employee {

int empno,dept;

char name[25];

Date d,j;

public:

void add() //function to add new emp record

{

char blkch;

clrscr( );

cout<<"Enter new employee details......\n"; cout<<"\n\

tEmployee Number [Numeric Value]: "; cin>>empno;

cin.get(blkch); cout<<"\n\

tName of the Employee: ";

cin.getline(name,25); P a g e | 10

Page 11: Project PaySlip 2016~vishal.d

cout<<"\n\tDepartment Code [Numeric Value]: ";

cin>>dept;

cout<<"\n\tDate of Birth (dd-mm-yy): ";

cin>>d.mm>>d.dd>>d.yy; cout<<"\n\

tDate of Joining (dd-mm-yy): ";

cin>>j.mm>>j.dd>>j.yy;

}

void show() // to display emp record

{

cout<<"\nEmp. No: ";

cout<<empno;

cout<<"\t Employee Name : ";

cout<<name;

cout<<"\t Dept. No. : ";

cout<<dept;

cout<<"\nDate of Birth : ";

cout<<d.mm<<"-"<<d.dd<<"-"<<d.yy;

cout<<"\t Date of Joining : ";

cout<<j.mm<<"-"<<j.dd<<"-"<<j.yy;

}

void report() // to display report in list form

{

gotoxy(3,k);

cout<<empno;

gotoxy(10,k);

puts(name);

gotoxy(20,k);

cout<<dept;

}

int retno() // accessors function

{

return(empno);

P a g e | 11

Page 12: Project PaySlip 2016~vishal.d

}

int retd() //accessors function

{

return(dept);

}

}; // end of class employee

class Salary: public employee // salary class inherited from employee

{

float basic,gross,deduction,da,hra; float

ot,oth,pf,lic,fadv,coops,hdfc,netpay;

int abdys; public:

void add();

void show();

void report();

void calculate();

void pay();

}sal;

void Salary::add() {

employee::add(); cout<<"\n\tBasic

Pay: [Numeric Value] "; cin>>basic;

cout<<"\n\tDays Absent: [Numeric Value] ";

cin>>abdys;

cout<<"\n\tOvertime Hours:[Numbers only ] ";

cin>>oth;

cout<<"\n\tLoans and Savings:::> ";

cout<<" LIC: "; cin>>lic;

cout<<"\n\t\t\t\tService Tax: ";

cin>>hdfc;

cout<<"\n\t\t\t\tCo-Operative Society: ";

cin>>coops; calculate();

fout.write((char *)&sal,sizeof(sal));

fout.close();

P a g e | 12

Page 13: Project PaySlip 2016~vishal.d

}

void Salary::calculate() {

hra=basic*0.1;

da=basic*0.225; ot=oth*700;

pf=basic*0.1275;

fadv=.02*basic;

gross=basic+hra+da+ot;

deduction=pf+lic+fadv+coops+hdfc;

netpay=gross-deduction;

}

void Salary::show() {

fin.open("database.dat",ios::binary);

fin.read((char*)&sal,sizeof(sal));

employee::show(); cout<<"\n\n\

t\t\t\tNet pay: "; cout<<netpay;

fin.close();

}

void Salary::report() // Report in listed form

{

employee::report();

gotoxy(30,k);

cout<<basic;

gotoxy(42,k);

cout<<gross;

gotoxy(52,k);

cout<<deduction;

gotoxy(67,k);

cout<<netpay;

k=k+1;

if(k==50)

P a g e | 13

Page 14: Project PaySlip 2016~vishal.d

{

gotoxy(25,50);

cout<<"PRESS ANY KEY TO CONTINUE...";

getch();

k=7;

clrscr();

gotoxy(30,3);

cout<<" EMPLOYEE DETAILS ";

gotoxy(3,5); cout<<"CODE";

gotoxy(10,5);

cout<<"NAME";

gotoxy(20,5);

cout<<"DEPT";

gotoxy(30,5);

cout<<"BASIC";

gotoxy(40,5);

cout<<"GROSS PAY";

gotoxy(52,5);

cout<<"DEDUCTION";

gotoxy(67,5);

cout<<"NETPAY";

}

}

void Salary::pay() {

show(); // Display employee details

cout<<"\

n**********************************************************"; cout<<"\n\t

SALARY SLIP OF THE MONTH - "; GetSysDate();

cout<<"\n___________________________________________________________";

cout<<"\n EARNINGS .......................................";

cout<<"\n\t\tBASIC SALARY :"<<basic; cout<<"\n\t\

tDEARNESS ALLOWANCE :"<<da; cout<<"\n\t\tHOUSE RENT

P a g e | 14

Page 15: Project PaySlip 2016~vishal.d

ALLOWANCE :"<<hra; cout<<"\n\t\tOVER TIME

HOURS :"<<oth; cout<<"\n\t\tOVER TIME WAGES :"<<ot;

cout<<"\n\t\tGROSS PAY :"<<gross;

cout<<"\n DEDUCTIONS.....................................";

cout<<"\n\t\tPROVIDENT FUND :"<<pf;

cout<<"\n\t\tLIC :"<<lic; cout<<"\n\t\tIncome

Tax :"<<fadv; cout<<"\n\t\tService

Tax :"<<hdfc; cout<<"\n\t\tCO-OP

Society :"<<coops;

cout<<"\n___________________________________________________________"; cout<<"\n\t\

tNET PAY :Rs."<<netpay;

cout<<"\n************************************************************";

}

void main()

{

cout.setf(ios::fixed);

cout.setf(ios::showpoint);

cout<<setprecision(2);

menu:

clrscr();

gotoxy(25,2);

cout<<"Company Employee Management";

gotoxy(25,3);

cout<<"===========================\n\

n"; cout<<"\n\t\t1.Salary Report\n\n";

cout<<"\t\t2.Edit Database\n\n"; cout<<"\t\

t3.Search\n\n"; cout<<"\t\t4.Pay Slip\n\n";

cout<<"\t\t5.Exit\n\n";

cout<<"\t\tEnter Your Choice (any from 1,2,3,4,5): ";

int ch;

cin>>ch;

switch(ch)

P a g e | 15

Page 16: Project PaySlip 2016~vishal.d

{

case 1:ss:

clrscr(); gotoxy(25,2);

cout<<"Salary

Statement"; gotoxy(25,3);

cout<<"==============

==\n\n"; cout<<"\n\t\

t1.All Employees\n\n";

cout<<"\t\t2.Department

wise\n\n"; cout<<"\t\

t3.Back to Main menu\n\

n";

cout<<"\t\tEnter Your Choice (any from 1,2,3): ";

int cho; cin>>cho;

if(cho==1) {clrscr();

gotoxy(30,3);

cout<<" EMPLOYEE DETAILS ";

gotoxy(3,5); cout<<"CODE";

gotoxy(10,5);

cout<<"NAME";

gotoxy(20,5);

cout<<"DEPT";

gotoxy(30,5);

cout<<"BASIC";

gotoxy(40,5);

cout<<"GROSS PAY";

gotoxy(52,5);

cout<<"DEDUCTION";

gotoxy(67,5);

cout<<"NETPAY";

fin.open("database.dat",ios::binary);

if(!fin)

P a g e | 16

Page 17: Project PaySlip 2016~vishal.d

{cout<<"\n\nFile Not Found...";

goto menu;} fin.seekg(0);

while(!fin.eof())

{fin.read((char*)&sal,sizeof(sal

)); if(!fin.eof())

sal.report();

}

getch();

fin.close();

}

if(cho==2)

{

flag=0;

cout<<"\n\t\tEnter Department: ";

int de; cin>>de;

clrscr();

gotoxy(30,3); cout<<"

EMPLOYEE DETAILS ";

gotoxy(3,5); cout<<"CODE";

gotoxy(10,5);

cout<<"NAME";

gotoxy(20,5);

cout<<"DEPT";

gotoxy(30,5);

cout<<"BASIC";

gotoxy(40,5);

cout<<"GROSS PAY";

gotoxy(52,5); cout<<"DEDUCTION";

gotoxy(67,5); cout<<"NETPAY";

fin.open("database.dat",ios::binary)

; if(!fin)

P a g e | 17

Page 18: Project PaySlip 2016~vishal.d

{cout<<"\n\nFile Not Found...";

goto menu;} fin.seekg(0);

while(!fin.eof())

{fin.read((char*)&sal,sizeof(sal)); if(!

fin.eof())

{int x=sal.employee::retd();

if(x==de)

{flag=1;

sal.report();}}}

if(flag==0)

{cout<<"\n\n\n\t\tDepartment doesnot exist...";

getch();

fin.close();

goto ss;}

getch();

fin.close();}

if(cho==3)

{goto menu;}

goto ss;

case 2:

db:

clrscr();

gotoxy(25,2);

cout<<"Employee Database";

gotoxy(25,3);

cout<<"=================\n\n"; cout<<"\n\t\

t1.Add Employee Details\n\n"; cout<<"\t\t2.Edit

Employee Details\n\n"; cout<<"\t\t3.Delete

Employee\n\n"; cout<<"\t\t4.Back to Main Menu ";

int apc; cin>>apc;

{ if(apc==1)

{

fout.open("database.dat",ios::binary|ios::app);

P a g e | 18

Page 19: Project PaySlip 2016~vishal.d

sal.add();

cout<<"\n\t\tEmployee Added Successfully!";

getch();

goto db;

}

if(apc==2)

{

int eno;

flag=0;

cout<<"\n\n\tEnter Employee Number to be Edited :";

cin>>eno;

fin.open("database.dat",ios::binary);

fout.open("database.dat",ios::binary|ios::app);

if(!fin)

{cout<<"\n\nFile Not Found...";

goto menu;}

fin.seekg(0);

r=0;

while(!fin.eof())

{

fin.read((char*)&sal,sizeof(sal));

if(!fin.eof())

{

r++;

int x=sal.employee::retno();

if(x==eno)

{

flag=1;

fout.seekp((r-1)*sizeof(sal));

clrscr();

cout<<"\n\t\tCurrent Details are\n";

sal.show();

P a g e | 19

Page 20: Project PaySlip 2016~vishal.d

cout<<"\n\n\t\tEnter New Details\n";

sal.add();

cout<<"\n\t\tEmployee Details editted";

}}}

if(flag==0)

{

cout<<"\n\t\tEmployee No does not exist...Please Retry!";

getch();

goto db;

}

fin.close();

getch();

goto db;

}

if(apc==3)

{

flag=0;

int eno;

cout<<"\n\n\tEnter Employee Number to be deleted :";

cin>>eno;

fin.open("database.dat",ios::binary); if(!

fin)

{

cout<<"\n\nFile Not Found..."; goto

menu;}

fstream tmp("temp.dat",ios::binary|ios::out);

fin.seekg(0);

while(fin.read((char*)&sal,

sizeof(sal))) {int

x=sal.employee::retno(); if(x!=eno)

tmp.write((char*)&sal,sizeof(sal));

else

P a g e | 20

Page 21: Project PaySlip 2016~vishal.d

{

flag=1;

}}

fin.close();

tmp.close();

fout.open("database.dat",ios::trunc|ios::binary);

fout.seekp(0);

tmp.open("temp.dat",ios::binary|ios::in);

if(!tmp)

{

cout<<"Error in File";

goto db;

}

while(tmp.read((char*)&sal,sizeof(sal)))

fout.write((char*)&sal,sizeof(sal));

tmp.close();

fout.close();

if(flag==1)

cout<<"\n\t\tEmployee Succesfully Deleted";

else if (flag==0)

cout<<"\n\t\tEmployee does not Exist! Please

Retry"; getch(); goto db;

}

if(apc==4)

{

goto menu;

}

if(apc>4)

{

cout<<"\n\n\t\tWrong Choice!!! Retry";

getch();

goto db;

P a g e | 21

Page 22: Project PaySlip 2016~vishal.d

}

}

case 3:clrscr();

cout<<"\n\n\t\tEnter Employee Number to be found: ";

flag=0;

int eno;

cin>>eno;

fin.open("database.dat",ios::binary);

if(!fin)

{cout<<"\n\nFile Not Found...";

goto menu;}

fin.seekg(0);

while(fin.read((char*)&sal, sizeof(sal)))

{int x=sal.employee::retno();

if(x==eno)

{flag=1;

cout<<"\n\n\t\tEmployee Details are \n"; cout<<"\t\

t====================\n";

sal.show();}}

fin.close();

if(flag==0) cout<<"\n\t\tEmployee does not exist....Please

Retry!"; getch(); goto menu;

case 4:clrscr();

flag=0;

cout<<"\n\n\t\tEnter Employee Number :";

cin>>eno;

fin.open("database.dat",ios::binary);

if(!fin)

{

cout<<"\n\nFile Not Found...\nProgram Terminated!";

goto menu;

}

fin.seekg(0);

P a g e | 22

Page 23: Project PaySlip 2016~vishal.d

while(fin.read((char*)&sal,sizeof(sal)))

{

int x=sal.employee::retno();

if(x==eno)

{

sal.pay();

flag=1;

break;

}}

if(flag==0)

cout<<"\n\t\tEmployee does not exist....Please Retry!";

getch();

fin.close();

goto menu;

case 5:clrscr();

gotoxy(20,20);

cout<<"ARE YOU SURE, YOU WANT TO EXIT

(Y/N)?"; char yn; cin>>yn; if((yn=='Y')||(yn=='y'))

{

gotoxy(10,5);

cout<<" EMPLOYEE PAYSLIP GENERATION PROGRAM ";

gotoxy(10,6);

cout<<"***************************************************"; gotoxy(10,8);

cout<<" C++ PROJECT FOR AISSCE 2016 PRACTICAL EXAMINATION ";

gotoxy(10,10);

cout<<"THIS PROJECT IS DEVELOPED BY D VISHAL OF K.V.2 HUBLI ";

gotoxy(10,12);

cout<<"THANKS TO DEEPAK GOSAIN SIR [PGT CS] FOR HELPING ME";

gotoxy(10,13);

cout<<"***************************************************";

getch();

exit(0);

}

P a g e | 23

Page 24: Project PaySlip 2016~vishal.d

else if((yn=='N')||(yn=='n'))

goto menu;

else

{

goto menu;

}

default:

cout<<"\n\n\t\tWrong Choice....Please Retry!";

getch(); goto menu;

}

}

INPUT /OUTPUT SCREEN SHOTS

MAIN MENU OF THE PROJECT

SALARY REPORT MENU

P a g e | 24

Page 25: Project PaySlip 2016~vishal.d

EDIT DATABASE MENU TO ADD/DELETE/EDIT EMPLOYEE DETAILS

Option 1 to Add New Employee Details

P a g e | 25

Page 26: Project PaySlip 2016~vishal.d

OPTION 4 OF MAIN MENU TO GENERATE MONTHLY SALARY

P a g e | 26

Page 27: Project PaySlip 2016~vishal.d

EMPLOYEE REPORT

C O N C L U S I O N

The application certainly has some striking feature over manual system. Some of

the main feature of this project is as follows:-

User queries have become quite accurate and efficient.

Lot of paper work has been eliminated.

Future modification and enhancements have become quite easier now in

comparison to the previous manual system.

The whole procedure will take too less time in comparison of the manual

system.

No doubt this project will be helpful for institutes in all procedure, which will be

monitoring through Account. At the first step this system will only be installed in the

any office with small number of employees.

The main advantage of this system is that, it will become a powerful tool in

establishment of better system in comparison of the existing system. It helps to protect

the system from the corruption. After installation of this system in institutions, there is

a greater possibility of stabilization a clear and fair system, which will be accurate,

update and fast.

P a g e | 27

Page 28: Project PaySlip 2016~vishal.d

There is no doubt that there always remains some scope of improvement. The

important thing is that the system developed should be flexible to accommodate any

future enhancements. This system can be used to provide some enhancement without

rewriting of existing code.

B I B L I O G R A P H Y

C++ BALAGURU SWAMI, SULTANCHAND PUBLICATION

C++ SUMITA ARORA, DHANPAT RAI CO. INC

THINKING IN C BY BRUCE ECKEL

SYSTEM ANALYSIS AND DESIGN BY ELIAS AWAD

INTERNET COLLECTION o C++ PROGRAMMING WORLD.

………………

……………….

………………..

HELP PROVIDED BY PGT COMPUTER SCIENCE

MR. DEEPAK GOSAIN

P a g e | 28