File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments