-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNestedSWitch.java
49 lines (45 loc) · 1.68 KB
/
NestedSWitch.java
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
import java.util.Scanner;
public class NestedSWitch {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int empID = in.nextInt();
String department = in.next();
switch (empID) {
case 1:
System.out.println("Jay Gondaliya");
break;
case 2:
System.out.println("Rahul Rana");
break;
case 3:
System.out.println("Emp Number 3");
switch (department) {
case "IT":
System.out.println("IT Department");
break;
case "Management":
System.out.println("Management Department");
break;
default:
System.out.println("No department entered");
}
break;
default:
System.out.println("Enter correct EmpID");
}
// ENHANCED SWITCH CASE
switch (empID) {
case 1 -> System.out.println("Jay Gondaliya");
case 2 -> System.out.println("Rahul Rana");
case 3 -> {
System.out.println("Emp Number 3");
switch (department) {
case "IT" -> System.out.println("IT Department");
case "Management" -> System.out.println("Management Department");
default -> System.out.println("No department entered");
}
}
default -> System.out.println("Enter correct EmpID");
}
}
}