-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEmployee Management System.java
More file actions
41 lines (36 loc) · 1.05 KB
/
Employee Management System.java
File metadata and controls
41 lines (36 loc) · 1.05 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
import java.util.*;
class Employee {
int id;
String name;
Employee(int i, String n) {
id = i;
name = n;
}
}
public class EmployeeManager {
public static void main(String[] args) {
ArrayList<Employee> list = new ArrayList<>();
Scanner sc = new Scanner(System.in);
while (true) {
System.out.println("1.Add 2.Delete 3.Show 4.Exit");
int ch = sc.nextInt();
if (ch == 1) {
System.out.print("ID: ");
int id = sc.nextInt();
sc.nextLine();
System.out.print("Name: ");
list.add(new Employee(id, sc.nextLine()));
}
else if (ch == 2) {
System.out.print("Enter ID: ");
int id = sc.nextInt();
list.removeIf(e -> e.id == id);
}
else if (ch == 3) {
for (Employee e : list)
System.out.println(e.id + " - " + e.name);
}
else break;
}
}
}