Requirements:
* Determine whether the year entered by the user is common year or leap years
Implementation code:
ImportJava.util.Scanner;/*** Required: * To determine whether the year entered by the user is common year or leap years *@authorAdministration **/ Public classJudge { Public Static voidMain (string[] args) {Scanner input=NewScanner (system.in); System.out.println ("Please enter a year:"); LongYear =Input.nextlong (); //leap years need to meet the conditions: can be divisible by 4 but not divisible by 100, or can be divisible by 400, to meet one can if((year%4==0 && year%100!=0) | | year%400==0) {System.out.println ( year+ "Years is a leap year! "); }Else{System.out.println ( year+ "Year is common year!" "); } }}
Operation Result:
Please enter a year:1000 is common year!
Please enter a year:2000 is leap years!
Java small case--to determine whether the given year is a common year or leap years