-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
214 lines (193 loc) · 6.82 KB
/
Main.java
File metadata and controls
214 lines (193 loc) · 6.82 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
import java.util.Scanner;
import java.util.HashMap;
import java.util.*;
class Employee
{
String eName;
int eAge;
int eID;
String ePosition;
int eSalary;
Employee()
{
eName="New";
eAge=24;
eID=0000;
ePosition="Fresher";
eSalary=10000;
}
Employee(String name, int age, int ID, String position, int salary)
{
eName=name;
eAge=age;
eID=ID;
ePosition=position;
eSalary=salary;
}
public void printDetails()
{
System.out.println(" ___________________________________");
System.out.println("|---------EMPLOYEE DETAILS---------|");
System.out.println("|NAME:"+eName);
System.out.println("|AGE:"+eAge);
System.out.println("|ID:"+eID);
System.out.println("|POSITION:"+ePosition);
int z=this.printSalary();
System.out.println("|SALARY:"+z);
System.out.println("|___________________________________");
}
public int printSalary()
{
if(ePosition.equals("CEO"))
{
eSalary=5000000;
}
else if(ePosition.equals("Manager"))
{
eSalary=1000000;
}
else if(ePosition.equals("Fresher"))
{
eSalary=400000;
}
return eSalary;
}
}
class opList
{
public void printOp()
{
System.out.println("____________________________________________________________________________________");
System.out.println("------------------------EMPLOYEE MANAGEMENT SYSTEM----------------------------------");
System.out.println("____________________________________________________________________________________");
System.out.println("_____________________________________");
System.out.println("|(1)Get Salary |");
System.out.println("|(2)Elligible for business trips |");
System.out.println("|(3)Remove employee |");
System.out.println("|(4)Search Employee |");
System.out.println("|(5)Get Details |");
System.out.println("|(6)EXIT |");
System.out.println("_____________________________________");
System.out.println("------------------------------------------------------------------------------------");
}
}
class Main
{
public static void main(String[] args)
{
String name,position;
int ID, age;
HashMap<Integer,Employee>eList= new HashMap<Integer,Employee>();
Scanner sc= new Scanner(System.in);
System.out.println("Enter number of employees: ");
int n= sc.nextInt();
while(eList.size()<n)
{
System.out.println("Enter ID:");
ID= sc.nextInt();
System.out.println("Enter employee name:");
name= sc.next();
System.out.println("Enter age:");
age= sc.nextInt();
System.out.println("Enter employee position:");
position= sc.next();
int sal=10000;
eList.put(ID,new Employee(name, age, ID, position, sal));
}
int choice=1;
while(choice!=6)
{
opList op=new opList();
op.printOp();
System.out.println("Enter the operation to perform:");
choice=sc.nextInt();
System.out.println("--------------------------------------------");
if(choice==1)
{
System.out.println("Enter the ID of employee:");
int x=sc.nextInt();
Employee e1=eList.get(x);
if(e1 != null)
{
int getsal=e1.printSalary();
System.out.println("Salary:"+getsal);
}
else{
System.out.println("Employee with ID "+x+" not found!");
}
}
else if(choice==2)
{
System.out.println("Enter work experience:");
int exp=sc.nextInt();
if(exp>5)
{
System.out.println("Elligible for business trip.");
}
else
{
System.out.println("Not elligible for business trip.");
}
}
else if(choice==3)
{
System.out.println("Enter no. of incomplete tasks:");
int incomp=sc.nextInt();
System.out.println("Enter employee ID:");
int remID=sc.nextInt();
Employee temp=eList.get(remID);
if(temp != null)
{
if(incomp>=1 && incomp<=5)
{
System.out.println("Warning!Finish task~"+temp.eName);
}
else if(incomp==0)
{
System.out.println("No pending works.Good job~"+temp.eName);
}
else
{
eList.remove(remID);
System.out.println("Due to inconsistent work "+temp.eName+" has been removed.");
}
}
else
{
System.out.println("Employee with ID "+remID+" not found!");
}
}
else if(choice==4)
{
System.out.println("Enter employee ID to search:");
int sID=sc.nextInt();
if(eList.containsKey(sID))
{
System.out.println("Employee found.");
}
else
{
System.out.println("Employee not found.");
}
}
else if(choice==5)
{
System.out.println("Enter the ID of employee:");
int x=sc.nextInt();
Employee e1=eList.get(x);
if(e1==null)
{
System.out.println("Employee(ID:"+x+") not found.");
}
else
{
e1.printDetails();
}
}
else
{
System.out.println("Invalid choice.");
}
}
}
}