三天打鱼两天晒网

/*中国有句俗语叫“三天打鱼两天晒网”。

某人从1990年1月1日起开始“三天打鱼两天晒网”,

编写程序判断这个人在以后的某天中是“打鱼”还是“晒网”。

要求结果用“fishing”或“sleeping”表示。*/

import java.util.Scanner;

public class 鱼 {

     public static void main(String[] args) {

          System.out.println("请输入年份");

          Scanner inYear=new Scanner(System.in);

          int year=inYear.nextInt();                  //输入年

          System.out.println("请输入月份:");

          Scanner inMonth=new Scanner(System.in);

          int month=inMonth.nextInt();                //输入月

          System.out.println("请输入日:");             //输入日

          Scanner inDay=new Scanner(System.in);

          int day=inDay.nextInt();

          int addDays=0;

          for(int j=1990;j

          {

               if(((j%4==0)&&!(j%100==0))||(j%400==0)){

                    addDays+=366;

               }else{

                    addDays+=365;

               }

          }

          for(int k=1;k

               switch(k){                               //以月份作为分支条件,累加天数

               case 1:

               case 3:

               case 5:

               case 7:

               case 8:

               case 10:

               case 12:

                    addDays+=31;                              

                    break;                                    //跳出switch语句

               case 4:

               case 6:

               case 9:

               case 11:

                    addDays+=30;                              

                    break;

               case 2:                                      //对于2月,根据是否为闰年判断当月天数

                    if(((k%4==0)&&!(k%100==0))||(k%400==0)){

                         addDays+=29;

                    }else{

                         addDays+=28;

                    }

                    break;

               }

          }

          addDays+=day;             //加上日的天数

          int j=addDays%5;

          if(j==1||j==2||j==3){         //判断是捕鱼还是晒网

               System.out.println("fishing");

          }else{

               System.out.println("seelping");

          }

     }

}

你可能感兴趣的:(三天打鱼两天晒网)