java-第五章-while-输入1~7,输入0结束循环,输出英文星期的缩写

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 A04 {
 
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Scanner input = new Scanner(System.in);
        System.out.print("请输入数字1~7(输入0结束):");
        int choice = input.nextInt();
        String show = "";
        while (choice != 0) {
            switch (choice) {
            case 1:
                show = "今天 是Mon";
                break;
            case 2:
                show = "今天 是Tue";
                break;
            case 3:
                show = "今天 是Wed";
                break;
            case 4:
                show = "今天 是Thu";
                break;
            case 5:
                show = "今天 是Fri";
                break;
            case 6:
                show = "今天 是Sat";
                break;
            case 7:
                show = "今天 是Sun";
                break;
            default:
                System.out.println("程序错误");
                return;
            }
 
            System.out.println(show);
            System.out.print("请输入数字1~7(输入0结束):");
            choice = input.nextInt();
        }
        System.out.println("程序结束!");
    }


上一篇:复习 if条件 for序列 for字典 循环退出 while


下一篇:千万级GPS数据接入案例分享