java switch实现三天打鱼,两天晒网

import java.util.Scanner;

public class test05 {

public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner scanner = new Scanner(System.in);

int sum=0;
int month,year,day,z;
z=0;
System.out.println("请输入年份:");
year=scanner.nextInt();
System.out.println("请输入月份:");
month=scanner.nextInt();
System.out.println("请输入日期:");
day=scanner.nextInt();
switch (month-1) {
case 11:
sum=sum+31;

case 10:
sum=sum+30;

case 9:
sum=sum+30;
case 8:
sum=sum+31;
case 7:
sum=sum+31;
case 6:
sum=sum+30;
case 5:
sum=sum+31;
case 4:
sum=sum+30;
case 3:
sum=sum+31;
case 2:
sum=sum+28;
case 1:
sum=sum+31;
case 0:
sum=sum+day;
default:

break;
}
if((year%4==0&&year/100!=0)||(year%4==0 && month>2)){
sum=sum+1;


}
if(sum%5==1 || sum%5==2 ||sum%5==3){
System.out.println("打鱼");
}else{
System.out.println("撒网");

}
System.out.println(sum);
}

}

java switch实现三天打鱼,两天晒网

 

上一篇:数组<一维,二维,向函数传递>


下一篇:前端项目打包优化