根据用户输入输出周几,输入0退出

时间:2021-02-03 20:45:54
 1 ublic static void main(String[] args) {
 2         // TODO Auto-generated method stub
 3 
 4         Scanner input = new Scanner(System.in);
 5         while (true) {
 6             System.out.println("输入1-7");
 7             int day = input.nextInt();
 8             if (day == 0) {
 9                 System.out.println("程序结束");
10                 break;
11             }
12             switch (day) {
13             case 1:
14                 System.out.println("今天是周1");
15                 break;
16             case 2:
17                 System.out.println("今天是周2");
18                 break;
19             case 3:
20                 System.out.println("今天是周3");
21                 break;
22             case 4:
23                 System.out.println("今天是周4");
24                 break;
25             case 5:
26                 System.out.println("今天是周5");
27                 break;
28             case 6:
29                 System.out.println("今天是周6");
30                 break;
31             case 7:
32                 System.out.println("今天是周7");
33                 break;
34             default:
35                 System.out.println("输入错误");
36                 break;
37 
38             }
39         }
40     }