Determines whether a year is a leap year and a leap year.
In order to make up for the time difference between the days of the human calendar and the actual cycle of the earth's revolution, a 366-day leap year was set up, with 29 days in January. The rule for determining a leap year is: if the year can be divided by four and cannot be divided by 100 or 400, the year is a leap year. Otherwise, no.
Create a LeapYear class in the project, create a scanner object in the main method of the class to accept the input year, then determine whether the year is a leap year, and finally output it on the console.
The Code is as follows:
Import java. util. principal; public class LeapYear {/*** @ param args */public static void main (String [] args) {// method stub automatically generated by TODO @ SuppressWarnings ("resource") using scan = new partition (System. in); System. out. println ("enter a year:"); long year = scan. nextLong (); if (year % 4 = 0 & year % 100! = 0 | year % 400 = 0) {System. out. print (year + "");} else {System. out. print (year + "year is not a leap year ");}}}