-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathswitch_statement.java
44 lines (41 loc) · 1.24 KB
/
switch_statement.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
import java.util.Scanner;
public class switch_statement {
public static void main(String[] args) {
// switch statement
Scanner sc = new Scanner(System.in);
System.out.print("Enter any number 1-7: ");
int day = sc.nextInt();
switch (day) {
case 1:
System.out.println("Monday");
break;
case 2:
System.out.println("Tuesday");
break;
default:
System.out.println("Wednesday to Sunday");
break;
}
// Another Example
System.out.print("Enter Any No. 1-3: ");
int abc = sc.nextInt();
switch (abc) {
case 1:
System.out.println("Khushboo");
break;
case 2:
System.out.println("Rehan");
break;
case 3:
System.out.println("Suhana");
break;
case 4:
System.out.println("Rijaan babu");
break;
default:
System.out.println("Stop call");
break;
}
sc.close();
}
}