1
1
#include < iostream>
2
- #include < string.h>
2
+ #include < string.h>
3
3
using namespace std ;
4
4
int obj;
5
5
class Employee
@@ -11,7 +11,7 @@ class Employee
11
11
12
12
public:
13
13
void accept ();
14
- int findEmploy (char *);
14
+ int findEmploy (char *);
15
15
void display ();
16
16
Employee ()
17
17
{
@@ -25,32 +25,29 @@ class Employee
25
25
26
26
void Employee ::accept ()
27
27
{
28
- cout << " \n Enter Employee details : \n " ;
29
-
30
-
31
- cout << " Name of Emplyee : " ;
32
- cin >> name;
33
- cout << " ID : " ;
34
- cin >> id;
35
- cout << " Salary : Rs. " ;
36
- cin >> salary;
37
- cout << " ---------------------------------------------" ;
28
+ cout << " Name of Employee : " ;
29
+ cin >> name;
30
+ cout << " ID : " ;
31
+ cin >> id;
32
+ cout << " Salary : Rs. " ;
33
+ cin >> salary;
34
+ cout << " ---------------------------------------------" ;
38
35
}
39
36
40
37
int Employee ::findEmploy (char *nm)
41
38
{
42
39
// b=strcmpi(s1,s2); -1 => s2 is before s1, 1 => s1 before s2, 0 => s1 equals s2
43
- if (strcmp (nm,name) == 0 )
44
- {
45
- return 1 ;
46
- }
47
- else
48
- return 0 ;
40
+ if (strcmp (nm, name) == 0 )
41
+ {
42
+ return 1 ;
43
+ }
44
+ else
45
+ return 0 ;
49
46
}
50
47
51
48
void Employee ::display ()
52
49
{
53
- cout << " \n Emplyee Name : " << name;
50
+ cout << " \n Employee Name : " << name;
54
51
cout << " \n ID : " << id;
55
52
cout << " \n Salary : Rs. " << salary << endl;
56
53
}
@@ -60,11 +57,11 @@ int main(void)
60
57
int n;
61
58
cout << " \n Enter number of employees : " ;
62
59
cin >> n;
63
- Employee e[n]; // creating an object of Employee
60
+ Employee e[n]; // creating an object of Employee
64
61
for (int i = 0 ; i < n; i++)
65
62
{
63
+ cout << " \n Enter details of employee " << i+1 << " : \n " ;
66
64
e[i].accept ();
67
-
68
65
}
69
66
cout << " \n\n >>>>>>>>>>>>>>>> LIST OF ALL EMPLOYEES WITH DETAILS <<<<<<<<<<<<<<<< \n " ;
70
67
for (int i = 0 ; i < n; i++)
@@ -73,22 +70,22 @@ int main(void)
73
70
cout << " \n ********************************************************************" ;
74
71
}
75
72
76
- int flag= 0 ;
73
+ int flag = 0 ;
77
74
char nam[100 ];
78
75
cout << " \n Enter employee name you want to search : " ;
79
76
cin >> nam;
80
77
81
- int i= 0 ,j= 0 ;
78
+ int i = 0 , j = 0 ;
82
79
for (i = 0 ; i < n; i++)
83
80
{
84
- j= e[i].findEmploy (nam);
85
- if (j == 1 )
81
+ j = e[i].findEmploy (nam);
82
+ if (j == 1 )
86
83
{
87
- flag= 1 ;
84
+ flag = 1 ;
88
85
break ;
89
86
}
90
87
}
91
- if (flag== 1 )
88
+ if (flag == 1 )
92
89
{
93
90
cout << " Employee name found!\n " ;
94
91
e[i].display ();
@@ -98,11 +95,11 @@ int main(void)
98
95
cout << " \n Employee name Not found." << endl;
99
96
}
100
97
cout << " \n ********************************************************************" ;
101
- // code to find highest salary :
102
- float max= e[0 ].salary ;
98
+ // code to find highest salary :
99
+ float max = e[0 ].salary ;
103
100
for (int i = 1 ; i < n; i++)
104
101
{
105
- if (max < e[i].salary )
102
+ if (max < e[i].salary )
106
103
{
107
104
max = e[i].salary ;
108
105
}
0 commit comments