Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
17
Task/Leap-year/Java/leap-year-1.java
Normal file
17
Task/Leap-year/Java/leap-year-1.java
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
import java.util.GregorianCalendar;
|
||||
import java.text.MessageFormat;
|
||||
|
||||
public class Leapyear{
|
||||
public static void main(String[] argv){
|
||||
int[] yrs = {1800,1900,1994,1998,1999,2000,2001,2004,2100};
|
||||
GregorianCalendar cal = new GregorianCalendar();
|
||||
for(int year : yrs){
|
||||
System.err.println(MessageFormat.format("The year {0,number,#} is leaper: {1} / {2}.",
|
||||
year, cal.isLeapYear(year), isLeapYear(year)));
|
||||
}
|
||||
|
||||
}
|
||||
public static boolean isLeapYear(int year){
|
||||
return (year % 100 == 0) ? (year % 400 == 0) : (year % 4 == 0);
|
||||
}
|
||||
}
|
||||
8
Task/Leap-year/Java/leap-year-2.java
Normal file
8
Task/Leap-year/Java/leap-year-2.java
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
import java.time.Year;
|
||||
|
||||
public class IsLeap {
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println(Year.isLeap(2004));
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue