package com.summer.cn; import java.util.Scanner; /** * @author Summer *输入一个数字,判断这个数字代表星期几 */ public class Test041508 { public static void main(String[] args) { //获取录入的一个数字 Scanner sc = new Scanner(System.in); System.out.println("请输入一个数字:"); int weekday = sc.nextInt(); //经过循环语句,输出相应的星期数 switch(weekday){ case 1: System.out.println("Monday"); break; case 2: System.out.println("Tuesday"); break; case 3: System.out.println("Wensday"); break; case 4: System.out.println("Thursday"); break; case 5: System.out.println("Friday"); break; case 6: System.out.println("Saturday"); break; case 7: System.out.println("Sunday"); break; default: System.out.println("请输入有效的数字"); } } }