练习1
练习2
练习3
代码如下:
package com.day;
import java.util.Scanner;
public class Exp11 {
static Scanner sc = new Scanner(System.in);
public static void main(String[] args) {
boolean flag = true;
while(flag){
System.out.print("请输入1-7(输入0结束):");
int i = sc.nextInt();
switch(i) {
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("今天是 FTI");
break;
case 6:
System.out.println("今天是 SAT");
break;
case 7:
System.out.println("今天是 SUN");
break;
default:
if(i == 0) {
flag = false;
}else {
System.out.println("请重新输入");
}
}
}
System.out.println("程序结束!");
}
}