package page_114;
import java.util.Scanner;
public class HomeWork5 {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.print("请输入数字1-7(输入0结束):");
int num = input.nextInt();
String day = "";
while (num != 0) {
if (num >= 1 && num <= 7) {
switch (num) {
case 1:
day = "MON";
break;
case 2:
day = "TUE";
break;
case 3:
day = "WED";
break;
case 4:
day = "THU";
break;
case 5:
day = "FRI";
break;
case 6:
day = "SAT";
break;
case 7:
day = "SUN";
break;
}
System.out.println("今天是 " + day);
System.out.print("请输入数字1-7(输入0结束):");
num = input.nextInt();
if (num == 0) {
System.out.println("程序结束!");
}
} else {
System.out.print("输入有误 请从新输入:");
num = input.nextInt();
}
}
}
}
import java.util.Scanner;
public class HomeWork5 {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.print("请输入数字1-7(输入0结束):");
int num = input.nextInt();
String day = "";
while (num != 0) {
if (num >= 1 && num <= 7) {
switch (num) {
case 1:
day = "MON";
break;
case 2:
day = "TUE";
break;
case 3:
day = "WED";
break;
case 4:
day = "THU";
break;
case 5:
day = "FRI";
break;
case 6:
day = "SAT";
break;
case 7:
day = "SUN";
break;
}
System.out.println("今天是 " + day);
System.out.print("请输入数字1-7(输入0结束):");
num = input.nextInt();
if (num == 0) {
System.out.println("程序结束!");
}
} else {
System.out.print("输入有误 请从新输入:");
num = input.nextInt();
}
}
}
}