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
|
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int num = 1;
while (num != -1){
System.out.println("1. Korea");
System.out.println("2. USA");
System.out.println("3. Japan");
System.out.println("4. China");
System.out.print("number? ");
num = sc.nextInt();
switch (num){
case 1:
System.out.printf("\nSeoul\n\n");
break;
case 2:
System.out.printf("\nWashington\n\n");
break;
case 3:
System.out.printf("\nTokyo\n\n");
break;
case 4:
System.out.printf("\nBeijing\n\n");
break;
default:
System.out.printf("\nnone\n\n");
break;
}
if ((num < 1) || (4 < num))
break;
}
}
}
|
cs |