-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathswitch10.java
More file actions
61 lines (52 loc) · 1.67 KB
/
switch10.java
File metadata and controls
61 lines (52 loc) · 1.67 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package swichcase;
import java.util.Scanner;
public class switch10 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
char y = scanner.next().charAt(0); // belgini kiritish
int k = scanner.nextInt();
// test1 : q 2
solution(y, k);
}
// char y - yo'nalish
// s - shimol, j-janub, q-sharq, g-g'arb
// int k - komanda :
// 0 - harakatni davam ettir
// 1 - chapga burilish
// 2 - o'ngga burilish
public static void solution(char y, int k) {
// y='q' k=1 -> shimol
String result = "";
String north = "shimol";
String south = "janub";
String sharq = "sharq";
String garb = "g'arb";
switch (k) {//davom ettir
case 0 -> {
switch (y) {
case 's' -> result = north;
case 'j' -> result = south;
case 'q' -> result = sharq;
case 'g' -> result = garb;
}
}
case 1 -> { // chapga
switch (y) {
case 's' -> result = garb;
case 'j' -> result = sharq;
case 'q' -> result = north;//Shimol
case 'g' -> result = south;//Janub
}
}
case 2 -> { // o'ngga
switch (y) {
case 's' -> result = sharq;
case 'j' -> result = garb;
case 'q' -> result = south;//Janub
case 'g' -> result = north;//Shimol
}
}
}
System.out.println(result);
}
}