Skip to content

Commit 6c5aa4c

Browse files
Employee Management System.java
1 parent 98b03f2 commit 6c5aa4c

1 file changed

Lines changed: 41 additions & 0 deletions

File tree

Employee Management System.java

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import java.util.*;
2+
3+
class Employee {
4+
int id;
5+
String name;
6+
7+
Employee(int i, String n) {
8+
id = i;
9+
name = n;
10+
}
11+
}
12+
13+
public class EmployeeManager {
14+
public static void main(String[] args) {
15+
ArrayList<Employee> list = new ArrayList<>();
16+
Scanner sc = new Scanner(System.in);
17+
18+
while (true) {
19+
System.out.println("1.Add 2.Delete 3.Show 4.Exit");
20+
int ch = sc.nextInt();
21+
22+
if (ch == 1) {
23+
System.out.print("ID: ");
24+
int id = sc.nextInt();
25+
sc.nextLine();
26+
System.out.print("Name: ");
27+
list.add(new Employee(id, sc.nextLine()));
28+
}
29+
else if (ch == 2) {
30+
System.out.print("Enter ID: ");
31+
int id = sc.nextInt();
32+
list.removeIf(e -> e.id == id);
33+
}
34+
else if (ch == 3) {
35+
for (Employee e : list)
36+
System.out.println(e.id + " - " + e.name);
37+
}
38+
else break;
39+
}
40+
}
41+
}

0 commit comments

Comments
 (0)