-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathHR.h
More file actions
269 lines (238 loc) · 8.75 KB
/
Copy pathHR.h
File metadata and controls
269 lines (238 loc) · 8.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
#ifndef HR_H
#define HR_H
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<bits/stdc++.h>
#include<conio.h>
using namespace std;
class hr
{
public:
string tname,tsur; //teacher or employee name & surname
string tdesig; // designation of teacher or employee
float tid; // teacher or employee id
float yr; // year or simply the age of employee
float sal_index; // sal_index is the absolute determining factor for salary for an emoloyee
float salary=15000; // the base salary declared in float which is 15000 rs
float exp; // experience of employee
void addata(); // function to add data , function declaration
void displaydat(); // function to dsiplay the data, function declaration
void deletedat(); // function to delete the data, function declaration
int option();
};
void hr::addata() // fucntion declaration
{
int j=j+1;
cout<<"Enter the name of employee "<<j<<":";
cin>>tname;
transform(tname.begin(), tname.end(), tname.begin(), ::toupper); // transform function to convert to upper case
cout<<"\nEnter the Surname of employee "<<j<<":";
cin>>tsur;
transform(tsur.begin(), tsur.end(), tsur.begin(), ::toupper);
cout<<"Enter the designation of employee "<<j<<":";
cin>>tdesig;
transform(tdesig.begin(), tdesig.end(), tdesig.begin(), ::toupper);
cout<<"\nEnter the employee id of employee "<<j<<":";
cin>>tid;
cout<<"\nEnter the age of employee "<<j<<":";
cin>>yr;
cout<<"\nEnter the experience of employee "<<j<<":";
cin>>exp;
if(yr>=45 && exp>=10)
{
sal_index=3;
}
if(yr>=45 && 10>exp<3) // SALARY CALCULATION MECHANISM
{
sal_index=2;
}
if(yr>=30 && 10>exp>=3)
{
sal_index=2.5;
}
if(45>yr>=24 && 10>exp>=1)
{
sal_index=1.5;
}
cout<<"Salary of the employee "<<j<<"is:";
salary=sal_index*salary; // OVERALL SALARY IS SAL_INDEX * BASE SALARY
cout<<salary<<endl;
}
void hr::displaydat() // FUNCTION TO DISPLAY DATA
{
int j=j+1;
cout<<"The name of employee "<<j<<" is:"<<tname<<" "<<tsur<<endl;
cout<<"The designation of employee "<<j<<" is:"<<tdesig<<endl;
cout<<"The id of employee "<<j<<" is:"<<tid<<endl;
cout<<"The age of employee "<<j<<" is:"<<yr<<endl;
cout<<"The Salary of employee "<<j<<" is:"<<salary<<endl;
}
void hr::deletedat() // FUNCTION TO DELETE DATA
{
tname='\0';
tsur='\0';
tdesig='\0';
tid=0;
yr=0;
sal_index=0;
salary=0;
cout<<"Your data has been sucessfully deleted!"<<endl;
}
int hr::option() // MAIN FUNCTION
{
int ch,i,maxtno,empid,age,ch1,se_choose;
string delchoose,modchoose,name,desig;
cout<<"Please enter the no of employees you want to enter the data for "<<endl;
cin>>maxtno;
hr hrs[maxtno]; // OBJECT CREATED UNDER CLASS HR
while(1){
cout<<"Enter \n1.To Change,review or dsiplay data \n2.To search through our database \n3. Exit"<<endl;
cout<<"**************************************************************************************************"<<endl;
cin>>ch1;
if(ch1==1)
{
cout<<"Enter \n1. to add data \n2. to delete data \n3. to modify data \n4. to display data "<<endl;
cin>>ch;
switch(ch) // SWITCH CASE TO CHOOSE THE MENU OPTIONS
{
case 1:
cout<<"you've choosen to add data "<<endl;
for(i=0;i<maxtno;i++)
{
hrs[i].addata();
}
break;
case 2:
cout<<"You've choosen to delete data "<<endl;
cout<<"Are you sure you want to delete the data "<<endl;
cout<<"\n1.yes \n2.no "<<endl;
cin>>delchoose;
if(delchoose=="yes"||delchoose=="YES")
{
for(i=0;i<maxtno;i++)
{
hrs[i].deletedat();
}
}
if(delchoose=="no"||delchoose=="NO")
{
cout<<"Your data is intact "<<endl;
}
break;
case 3:
cout<<"you've choosen to modify data "<<endl;
cout<<"The Data of employees will be displayed you can choose to either modify it or keep it intact "<<endl;
for(i=0;i<maxtno;i++)
{
hrs[i].displaydat();
cout<<"*******************************************************************************************"<<endl;
}
cout<<"Do you want to make any changes to the data ?"<<endl;
cout<<"1.yes\n2.no"<<endl;
cin>>modchoose;
if(modchoose=="yes"||modchoose=="YES")
{
for(i=0;i<maxtno;i++)
{
hrs[i].addata();
}
}
if(modchoose=="no"||modchoose=="NO")
{
cout<<"Your data is intact "<<endl;
}
break;
case 4:
cout<<"you've choosen to display data "<<endl;
for(i=0;i<maxtno;i++)
{
hrs[i].displaydat();
cout<<"**********************************************************************"<<endl;
}
break;
default :
cout<<"Wrong choice "<<endl;
break;
}
}
if(ch1==2)
{
cout<<"Hey there what do you want to search by : \n1.Name \n2.Designation \n3.Employee id \n4.Age "<<endl;
cin>>se_choose;
switch(se_choose) //SWITCH FOR SEARCHING THE DATABASE
{
case 1:
cout<<"You've choosen to search by Name, please enter the Name to find it in our database "<<endl;
cin>>name;
for(i=0;i<maxtno;i++)
{
if(name==hrs[i].tname)
{
hrs[i].displaydat();
cout<<"------------------------------------------------------------------------------------------"<<endl;
}
else
{
cout<<"Error name not found in our database "<<endl;
}
break;
}
break;
case 2:
cout<<"You've choosen to search by designation, please enter the designation to find it in our database "<<endl;
cin>>desig;
for(i=0;i<maxtno;i++)
{
if(desig==hrs[i].tdesig)
{
hrs[i].displaydat();
cout<<"------------------------------------------------------------------------------------------------------------------------------"<<endl;
}
else
{
cout<<"Error designation not found in our database "<<endl;
}
break;
}
break;
case 3:
cout<<"You've choosen to search by Employee id, please enter the Employee id to find it in our database "<<endl;
cin>>empid;
for(i=0;i<maxtno;i++)
{
if(hrs[i].tid==empid)
{
hrs[i].displaydat();
cout<<"----------------------------------------------------------------------------------------------------------------------------------"<<endl;
}
else{
cout<<"Error Employee id not found "<<endl;
}
break;
}
break;
case 4:
cout<<"You've choosen to search by Age, please enter the age of Employee to find it in our database "<<endl;
cin>>age;
for(i=0;i<maxtno;i++)
{
if(hrs[i].yr==age)
{
hrs[i].displaydat();
cout<<"--------------------------------------------------------------------------------------------------------------------------------"<<endl;
}
else
{
cout<<"Error Employee age not found "<<endl;
}
break;
}
break;
}
}
if(ch1==3)
return 0;
}
}
#endif