Computer Project - NIRMAL VIDALAYA
Computer Project - NIRMAL VIDALAYA
In the Computer lab during the year 2012-13 Date P.G.T Computer
Computer LAB
at
Nirmal Vidyalay
Date:
Nirmal Vidyalay
ACKNOWLEDGEMENT
We would like to express our sincere gratitude to our Computer mentors Mr. K. Shreedhar Sir and Mr. Pratap Sir for their vital support, guidance and encouragement - without which this project would not have come forth. This project helped us to imbibe program writing skills based on real life problems. The project took our understanding of programming in C++ to another level. We would also like to thank our classmates for their constant help and support which encouraged us to complete our project on time.
Contents
1) Aim of Project
2) Program listing
3) Input data
4) Output data
5) Commands used
6) Implementation
7) Conclusion
AIM OF PROJECT
To develop software for ABC Company to generate salary statement according to the employees basic salary by providing following allowances:If basic >=5,000 :1) Provide 70% DA (Dearness Allowance). 2) Provide 30% HRA (House Rent Allowance) 3) Provide 15% TA (Travelling Allowance) If basic <5,000 :1) Provide 65% DA (Dearness Allowance). 2) Provide 25% HRA (House Rent Allowance) 3) Provide 10% TA (Travelling Allowance) Deduct PF from Net salary, Net Salary = basic+HRA+DA+TA
If Net salary >=7,000 then 5% PF of Net salary If Net salary <7,000 then 2% PF of Net salary Gross = Net-PF
Generate a record for at least 10 employees and store all the data in employee.txt file.
PROGRAM LISTING:#include<conio.h> #include<stdio.h> #include<dos.h> #include<process.h> #include<fstream.h> operations class Graphics { public: void frame1(); void frame2(); void frame3(); void progress(); }; /* Prototype declared */ //for gets() //for delay() //for exit() //for file handling
void Graphics::frame1() //Member function defined outside // class { for(int x=10; x<=50; x++) { gotoxy(x,3); coordinate (x,3) cout<<""; gotoxy(x,23); cout<<""; } for(int y=3; y<=23; y++) { gotoxy(10,y); cout<<""; gotoxy(50,y); cout<<""; } } void Graphics::frame2() { //moves cursor to
gotoxy(22,2); cout<<"ABC COMPANY - MENU"; for(int x=20; x<=40; x++) { gotoxy(x,3); cout<<""; gotoxy(x,23); cout<<""; } for(int y=3; y<=23; y++) { gotoxy(20,y); cout<<""; gotoxy(40,y); cout<<""; } gotoxy(22,5); cout<<"1 - Add Employee"; gotoxy(22,7); cout<<"2 - Search Emp."; gotoxy(22,9);
cout<<"3 - Search Sal."; gotoxy(22,11); cout<<"4 - List Emp."; gotoxy(22,13); cout<<"5 - Delete all"; gotoxy(22,15); cout<<"6 - Exit"; gotoxy(21,17); cout<<"___________________"; gotoxy(22,19); cout<<"Input option : "; } void Graphics::frame3() { for(int x=2; x<=72; x++) { gotoxy(x,1); cout<<""; } for(x=2; x<=72; x++) {
gotoxy(x,25); cout<<""; } gotoxy(2,2); cout<<"Name"; gotoxy(20,2); cout<<"Basic"; gotoxy(28,2); cout<<"DA"; gotoxy(36,2); cout<<"TA"; gotoxy(44,2); cout<<"HRA"; gotoxy(52,2); cout<<"Net"; gotoxy(60,2); cout<<"PF"; gotoxy(68,2); cout<<"Gross"; gotoxy(2,3);
cout<<"_______________________________________ ________________________________"; } void Graphics::progress() { gotoxy(20,8); cout<<"Loading..."; for(int x=20; x<=40; x++) { gotoxy(x,10); cout<<""; gotoxy(x,12); cout<<""; } gotoxy(20,10); cout<<""; gotoxy(20,11); cout<<""; gotoxy(20,12); cout<<""; gotoxy(40,10);
public: void getPersonal(); void printPer(); }; void Personal::getPersonal() { clrscr(); Graphics g; g created g.frame1(); gotoxy(22,4); cout<<"PERSONAL DETAILS"; gotoxy(13,8); cout<<"Employee's name : "; gotoxy(13,10); cout<<"F/H name gotoxy(13,12); cout<<"Address gotoxy(32,8); gets(name); gotoxy(32,10); gets(fname); : "; : "; //Object of Graphics class
gotoxy(32,12); gets(address); } void Personal::printPer() { clrscr(); Graphics g; g.frame1(); gotoxy(22,4); cout<<"PERSONAL DETAILS"; gotoxy(13,8); cout<<"Employee's name : "<<name; gotoxy(13,10); cout<<"F/H name gotoxy(13,12); cout<<"Address } : "<<address; : "<<fname;
public: long idno; float bs, ns, gs; float ta, da, hra; float pf;
public: void getEmp(); void printEmp(); void listEmp(int); }; void Employee::getEmp() { getPersonal(); clrscr(); Graphics g; g.frame1(); gotoxy(22,4); cout<<"SALARY DETAILS"; gotoxy(13,6); cout<<"ID No. : ";
gotoxy(13,8); cout<<"Basic salary : "; gotoxy(13,10); cout<<"D.A. gotoxy(13,12); cout<<"T.A. gotoxy(13,14); cout<<"H.R.A. gotoxy(13,16); cout<<"Net salary : "; gotoxy(13,18); cout<<"P.F. gotoxy(13,20); cout<<"Gross salary : "; : "; : "; : "; : ";
if(bs<5000)
{ da=bs*65/100; ta=bs*10/100; hra=bs*25/100; gotoxy(13,10); cout<<"D.A. (65%) : "; gotoxy(13,12); cout<<"T.A. (10%) : "; gotoxy(13,14); cout<<"H.R.A.(25%) : "; } else { da=bs*70/100; ta=bs*15/100; hra=bs*30/100; gotoxy(13,10); cout<<"D.A. (70%) : "; gotoxy(13,12); cout<<"T.A. (15%) : "; gotoxy(13,14);
if(ns<7000) { pf=ns*2/100; gotoxy(13,18); cout<<"P.F. (2%) : "; } else { pf=ns*5/100; gotoxy(13,18); cout<<"P.F. (5%) : "; } gs=ns-pf;
cout<<ta; gotoxy(30,14); cout<<hra; gotoxy(30,16); cout<<ns; gotoxy(30,18); cout<<pf; gotoxy(30,20); cout<<gs; } void Employee::printEmp() { clrscr(); Graphics g; g.frame1(); gotoxy(22,4); cout<<"SALARY DETAILS"; gotoxy(13,6); cout<<"ID No. gotoxy(13,8); cout<<"Basic salary : "<<bs; : "<<idno;
gotoxy(13,10); cout<<"D.A. gotoxy(13,12); cout<<"T.A. gotoxy(13,14); cout<<"H.R.A. gotoxy(13,16); cout<<"Net salary : "<<ns; gotoxy(13,18); cout<<"P.F. gotoxy(13,20); cout<<"Gross salary : "<<gs; } void Employee::listEmp(int y) { gotoxy(2,y); cout<<name; gotoxy(20,y); cout<<bs; gotoxy(28,y); : "<<pf; : "<<hra; : "<<ta; : "<<da;
cout<<da; gotoxy(36,y); cout<<ta; gotoxy(44,y); cout<<hra; gotoxy(52,y); cout<<ns; gotoxy(60,y); cout<<pf; gotoxy(68,y); cout<<gs; } void main() { clrscr(); Graphics G; Employee E; int op; int id; fstream file; file G.progress(); // Input and output
clrscr(); while(1) { clrscr(); G.frame2(); gotoxy(37,19); cin>>op; switch(op) { case 1: E.getEmp(); file.open("employee.txt",ios::app); // employee linked //with file in I/O mode file.seekp(0,ios::end); end of file //go to
file.write((char*)&E, sizeof(E));// write to employee file.close(); //de-link employee from file (stream object) break;
file.open("employee.txt",ios::in); file.seekg(0,ios::beg); get_pointer to beginning int c=0; while(file.read((char*)&E, sizeof(E))) { if(id==E.idno) { E.printPer(); c++; } } if(c==0) { // moves // of file
{ E.printEmp(); c++; } } if(c==0) { clrscr(); G.frame1(); gotoxy(20,11); cout<<"ID No does not exist!!!"; } file.close(); break; case 4: clrscr(); G.frame3();
getch(); } getch(); }
INPUT LISTING:PERSONAL DETAILS:Employees Name : Sumit Sahu F/H Name Address ID No. Basic Salary : Suresh Sahu : Dharampura :1 : 15000
Employees Name : Manish Sahu F/H Name Address ID No. Basic Salary : Jagdish Sahu : PHE-H-14 :2 : 16000
Employees Name : Bhupendra Parganiha F/H Name Address ID No. Basic Salary : Rajendra Parganiha : Avantika Colony, G-7 :3 : 14000
Employees Name : Mihir Pradhan F/H Name Address ID No. Basic Salary : Abhimanyu Pradhan : B.R Cold Storage (P) LTD :4 : 17000
Employees Name : Gaurav Arora F/H Name Address ID No. Basic Salary : Vipin Arora : Pratapganj :5 : 13000
Employees Name : Shubham Basrani F/H Name Address ID No. Basic Salary : Aditya Basrani : Kumharpara :6 : 20000
Employees Name : Shubham Shukla F/H Name Address ID No. Basic Salary : Purshottam Shukla : Nayapara :7 : 21000
Employees Name : Akash Khambari F/H Name Address ID No. Basic Salary : Ishwarnath Khambari : Aasna :8 : 19000
Employees Name : Tobia John F/H Name Address ID No. Basic Salary : Matthew John : Avantika Colony :9 : 18000
Employees Name : Manoj Tiwari F/H Name Address ID No. Basic Salary : Mukesh Tiwari : Patparganj : 10 : 17000
OUTPUT LISTING:Name Sumit Sahu Manish Sahu Bhupendra Parganiha Mihir Pradhan Gaurav Arora Shubham Basrani Shubham Shukla Akash Khambari Basic DA TA 2250 2400 H RA 4500 4800 Net 32250 34400 PF 1612.5 17201 Gross 30637.5 32680 15000 10500 16000 11200
14000
9800
2100
4200
30100
1505
28595
17000 11900
2550
5100
36550
1827.5
34722.5
13000
9100
1950
3900
27950
1397.5
26552.5
20000 14000
3000
6000
43000
2150
40850
21000 14700
3150
6300
45150
2257.5
42892.5
19000 13300
2850
5700
40850
2042.5
38807.5
2700 2550
5400 5100
38700 36550
1935 1827.5
36765 34722.5
Salient Features:i) In our program we can also search for an Employees personal details through his ID No. Sample run for an employee is given below:
Input ID No. : 4
PERSONAL DETAILS
If the entered ID No. does not exist, error message is printed as described below :
Input ID No. : 11
ii)
In this program we can also search the Salary Details of an employee through his ID No. Sample run for an employee is given below:
Input ID No. : 9
SALARY DETAILS
ID No. Basic Salary D.A. T.A. H.R.A. Net Salary P.F. Gross Salary :9 : 18000 : 12000 : 2700 : 5400 : 38700 : 1935 : 36765
If the entered ID No. does not exist, error message is printed as described below:
Input ID No. : 21
#include<fstream.h>
#include<conio.h>
#include<dos.h>
#include<iomanip.h>
#include<process.h>
It is the header file for exit(). A function to move the cursor to coordinate s specified by x and y. It is an exit controlled loop used to repeat some program code a given number of time. It is a decision making statement which checks for the truth value of a given condition and then executes the proceeding code.
gotoxy();
gotoxy(x,y);
Graphics g;
Class_name Object_name;
This command creates an object of the Classname. This command is used to define a function outside the class definition. This command calls the public member function of the Class. To inherit a class(Base Class) publicly into another class(Deriv ed Class). Creates an inputoutput stream.
11
g.frame1();
Object_Name.Function_ Name();
12
13
fstream file();
14
15
file.seekp(0,ios::end);
Command to move Stream_Object.seekp(0, put_pointer ios ::{beg,cur,end}); to desired location in file. Stream_Object.write((ch ar*)&buf,sizeof(buf)); Command to write a class to a file.
16
file.write((char*)&E, sizeof(E));
17
file.seekg(0,ios::beg);
Command to move Stream_Object.seekg(0, get_pointer ios::{beg,cur,end}); to desired location in file. Stream_Object.read((ch ar*)&buf,sizeof(buf)); Command to read a class from a file. Terminate association with file.
18
file.read((char*)&E, sizeof(E));
19
file.close();
stream_object.close();
IMPLEMENTATION:We can supply a number of other functions in this program. The above program can be modified and can offer facilities such as:-
We can design one more program to read data from file and can provide following functions:
Search any employees detail by code. View monthly income of all employees.
We can also design a program for candidates seeking employment in the company. The program can have functions for following specifications:-