循环输入1-7的数字得到星期几
1 import java.util.Scanner; 2 public class LianXi{ 3 public static void main(String[] args){ 4 System.out.println("请输入1-7的数字"); 5 Scanner sc = new Scanner(System.in); 6 for(int i=1;i<=7;i++){ 7 int week = sc.nextInt(); 8 switch(week){ 9 case 1: 10 System.out.println("星期一"); 11 break; 12 case 2: 13 System.out.println("星期二"); 14 break; 15 case 3: 16 System.out.println("星期三"); 17 break; 18 case 4: 19 System.out.println("星期四"); 20 break; 21 case 5: 22 System.out.println("星期五"); 23 break; 24 case 6: 25 System.out.println("星期六"); 26 break; 27 case 7: 28 System.out.println("星期天"); 29 break; 30 default: 31 System.out.println("您的输入有误"); 32 break; 33 } 34 } 35 } 36 }
乐观的心态会让你更加完美