代码:
package test3;
import java.util.Scanner;
public class Week {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
boolean flag =true;
do {
System.out.print("请输入数字1~7(输入0时结束):");
int num = input.nextInt();
switch(num){
case 0:
flag = false;
System.out.println("程序结束!");
break;
case 1:
System.out.println("今天是星期一, MON");
break;
case 2:
System.out.println("今天是星期二,TUE");
break;
case 3:
System.out.println("今天是星期三, WEN");
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("请重新输入1~7数字(输入0时结束)");
}
}while(flag);
}
}
运行结果: