我是靠谱客的博主 结实台灯,这篇文章主要介绍编写程序,判断给定的某个年份是否是闰年。,现在分享给大家,希望可以做个参考。

编写程序,判断给定的某个年份是否是闰年。       
闰年的判断规则如下: 
(1)若某个年份能被4整除但不能被100整除,则是闰年。       
(2)若某个年份能被400整除,则也是闰年。
解答:

import java.util.*;
public class Bissextile{
public static void main(String[]arge){
System.out.println("please input the nian:");
int year;
Scanner scanner = new Scanner(System.in);
year = scanner.nextInt();
if(year<0||year>3000){
System.out.println("the Year is wrong,exit!");
System.exit(0);
}
if((year%4==0)&&(year%100!=0)||(year%400==0))
System.out.println(year+"is bissextile");
else
System.out.println(year+"is not bissextile");
}
}

2015-01-19 23:38:36

转载于:https://www.cnblogs.com/Rainbow-G/p/4235046.html

最后

以上就是结实台灯最近收集整理的关于编写程序,判断给定的某个年份是否是闰年。的全部内容,更多相关编写程序,判断给定内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(97)

评论列表共有 0 条评论

立即
投稿
返回
顶部