forked from 1laurelverma/DSA-Solutions
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathManagementSystem.cpp
More file actions
257 lines (221 loc) · 5.23 KB
/
Copy pathManagementSystem.cpp
File metadata and controls
257 lines (221 loc) · 5.23 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
#include <bits/stdc++.h>
using namespace std;
//----------------------QUESTION 1----------------------
class Employee
{
public:
string firstName;
string lastName;
string employeeID;
float basicSal;
int allowancePercent;
public:
int findEmployeeSalary(string employee_id);
void printEmployeeDetail(int i);
void createEmployee();
void findEmployeeById();
void findEmployeeByName();
} employee[11];
int total_employees = 0;
int findEmployeeSalary(string employee_id)
{
int flag = -1;
string employeeID;
employeeID = employee_id;
for (int i = 0; i < total_employees; i++)
{
if (employee[i].employeeID == employeeID)
{
flag = i;
break;
}
}
int calculate = employee[flag].basicSal + (employee[flag].basicSal * employee[flag].allowancePercent) / 100;
if (flag != -1)
{
return calculate;
}
else
{
cout << "Your ID doesnt exist\n";
return 0;
}
}
void printEmployeeDetail(int i)
{
cout << "NAME: " + employee[i].firstName + employee[i].lastName<<"\n";
cout << "ID: " << employee[i].employeeID << "\n";
cout << "Salary: " << findEmployeeSalary(employee[i].employeeID) << "\n";
cout << "Allowance Percentage: " << employee[i].allowancePercent << "\n";
cout << "\n";
}
void createEmployee()
{
string firstName;
string lastName;
string employeeID;
int nc = 0, flag = 1;
float basicSal;
cout << "Enter Employee ID: ";
cin >> employeeID;
for (int i = 0; i < total_employees; i++)
{
if (employee[i].employeeID == employeeID)
{
cout << "ID already exists" << endl;
flag = 0;
break;
}
}
if (flag)
{
employee[total_employees].employeeID = employeeID;
cout << "First Name: ";
cin >> firstName;
employee[total_employees].firstName = firstName;
cout << "Last Name: ";
cin >> lastName;
employee[total_employees].lastName = lastName;
cout << "Salary: ";
cin >> basicSal;
employee[total_employees].basicSal = basicSal;
cout << "Allowance Percentage: ";
cin >> nc;
employee[total_employees].allowancePercent = nc;
total_employees++;
cout << "\n\nRecord Resgistered\n\n\n";
}
}
void findEmployeeById()
{
int flag = -1;
string employeeID;
cout << "Enter Employee ID:";
cin >> employeeID;
for (int i = 0; i < total_employees; i++)
{
if (employee[i].employeeID == employeeID)
{
flag = i;
break;
}
}
if (flag != -1)
{
printEmployeeDetail(flag);
}
else
cout << "Your ID doesnt exist\n";
}
void findEmployeeByName()
{
string name;
int flag = 1;
cout << "Enter the employee name: ";
fflush(stdin);
getline(cin, name);
for (int i = 0; i < total_employees; i++)
{
if (employee[i].firstName + " " + employee[i].lastName == name)
{
flag = 0;
printEmployeeDetail(i);
}
}
if (flag)
cout << "This name is not found" << endl;
}
//----------------------QUESTION 2----------------------
class hospitaldetails
{
private:
string patientname;
string doctorname;
public:
void input();
void display();
}patient[10];
int total=0;
void hospitaldetails::input()
{
cout<<"Enter Patient name:";
cin>>patient[total].patientname;
cout<<"Enter Doctor name:";
cin>>patient[total].doctorname;
total++;
}
void hospitaldetails::display()
{
for(int i=0;i<total;i++){
cout<<"\nName:"<<patient[i].patientname;
cout<<"\nDoctor's Name:"<<patient[i].doctorname;
}
}
int Q1()
{
cout<<"----------------------QUESTION 1----------------------"<<"\n\n";
int func, close = 0;
while (1)
{
cout << "Please enter function\n"
"1. Create an Employee\n"
"2. Find Employee By ID\n"
"3. Find Employee By Name\n"
"4. Find Employee Salary\n"
"5. End Task\n";
cin >> func;
if (func == 1)
{
createEmployee();
}
else if (func == 2)
{
findEmployeeById();
}
else if (func == 3)
{
findEmployeeByName();
}
else if (func == 4)
{
cout << "Enter employee id: ";
string id;
cin >> id;
cout << "\n\nSalary: " << findEmployeeSalary(id) << endl
<< "\n\n";
}
else if (func == 5)
{
break;
}
}
return 0;
}
int Q2()
{
cout<<"----------------------QUESTION 2----------------------"<<"\n\n";
cout<<"1-Enter Patient Details \n2-Display Records\n3-Exit Task\n";
int ch;
hospitaldetails s;
while(1){
cin>>ch;
if(ch==3){
break;
}
switch(ch){
case 1:
s.input();
break;
case 2:
s.display();
break;
default:
break;
}
}
}
int main()
{
Q1();
Q2();
}