判断瑞年 条件:能被4整除,但不能被100整除;能被400整除

输入年分  

输出是非是瑞年;代码如下:

import java.util.Scanner;

public class ruinian {
	public static void main(String[] args) {
		System.out.print("请输入年份:");
		Scanner input = new Scanner(System.in);	
		int year = input.nextInt();
		if(year % 4 == 0 && year % 100 != 0||year % 400 == 0) {
			System.out.print(year + "是瑞年");
		}
		else
		{
			System.out.print(year + "不是瑞年");
		}
		
	}

}

运行结果如下:

请输入年份:2200
2200不是瑞年


版权声明:本文为qq_52253798原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。