判断闰年

 1 package test;
 2 
 3 import java.util.Scanner;
 4 
 5 public class LeapYear {
 6 
 7     public static void main(String[] args) {
 8         // TODO Auto-generated method stub
 9 
10         Scanner input = new Scanner(System.in);
11         System.out.print("Enter a year:");
12         int year = input.nextInt();
13         
14         boolean isLeapYear =
15                 (year % 4 == 0 && year % 100 !=0 ||year % 400 ==0);
16         
17         System.out.println(year + " is a leap year? " + isLeapYear);
18     }
19 
20 }

 

posted @ 2019-03-08 21:18  殇之弑梦  阅读(132)  评论(0编辑  收藏  举报