判断某年是否是闰年的JAVA程序

需积分: 50 7 下载量 191 浏览量 更新于2024-01-14 1 收藏 102KB DOC 举报
The given Java program is used to determine whether a given year is a leap year or not. A leap year is a year that is evenly divisible by 4 but not by 100, unless it is also divisible by 400. The program starts by prompting the user to enter a year. It then reads the inputted year using the Scanner class. If the year is less than 0 or greater than 3000, the program prints an error message and exits. Next, the program checks whether the year is divisible by 4 using the modulo operator (%). If the remainder is 0, it proceeds to the next condition. If the remainder is not 0, it is not a leap year. If the year is divisible by 4, the program checks whether it is also divisible by 100. If the remainder is not 0, it is a leap year. If the year is divisible by 100, the program checks whether it is also divisible by 400. If the remainder is 0, it is a leap year. Finally, the program prints whether the given year is a leap year or not based on the conditions mentioned above. Overall, the program efficiently determines whether a given year is a leap year or not based on the given conditions. It is a classic example of using logical operators and control flow in Java programming.