//*******根据键盘录入的索引,查找对应的星期******
import java.util.Scanner;
class ziXi3 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("请输入星期,范围在1-7 : ");
int x = sc.nextInt();
System.out.println("星期" + getWeek(x));
}
/*1,明确返回值类型:char
2,明确参数列表:int a
*/
public static char getWeek(int a) {
char[] arr = {' ','一','二','三','四','五','六','日',};
//System.out.println(arr[a]);
return arr[a];
}
} |
|