第五章練習題5

Duanhaifeng55發表於2018-04-02


public static void five() {

int num=0;
do {
System.out.println("請輸入數字1-7(輸入0結束)");
Scanner input = new Scanner(System.in);
num=input.nextInt();
switch(num) { 
case 1:
System.out.println("今天是 MON");
break;
case 2:
System.out.println("今天是 TUE");
break;
case 3:
System.out.println("今天是  WED");
break;
case 4:
System.out.println("今天是 THU");
break;
case 5:
System.out.println("今天是 FRI");
break;
case 6:
System.out.println("今天是 SAT");
break;
case 7:
System.out.println("今天是 SUN");
break;
default:
System.out.println("輸入有誤請重新輸入:");
}
}while(num!=0);
System.out.println("程式結束");


}
}