package Demo;
/*
* 根据给定的数字,输出对应得星期:使用查表法,不能用判断!
* 存在有序的对应关系,利用数组!
*/
import java.util.*;
public class Demo13 {
public static void main(String [] args) {
System.out.println("请输入数字,系统将显示对应得星期");
Scanner input = new Scanner(System.in);
int a = input.nextInt();
String b = getWeek(a);
System.out.println(b);
}
public static String getWeek(int num) {
if(num>7||num<0) {
throw new RuntimeException(num+"没有对应的星期");
}
String [] week = {"","星期一","星期二","星期三","星期四","星期五","星期六","星期日"};
return week[num];
}
}