-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLeapYear2.java
More file actions
executable file
·31 lines (26 loc) · 969 Bytes
/
Copy pathLeapYear2.java
File metadata and controls
executable file
·31 lines (26 loc) · 969 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
//**************************************************************
// LeapYear2.java
//
// Asks user for a year and checks to see if it is a leap year.
//**************************************************************
import java.util.Scanner;
public class LeapYear2
{
public static void main(String args[])
{
int year;
Scanner scan = new Scanner(System.in);
System.out.print("Enter a year XXXX (0 to quit): ");
year = scan.nextInt();
while (year != 0) {
if (year < 1582)
System.out.println("The Gregorian calender was apoted in 1582. Year must not be less than 1582.");
else if ( (year % 400 == 0) || ( (year % 4 == 0) && (year % 100 != 0) ) )
System.out.println("" + year + " is a leap year");
else
System.out.println(year + " is NOT a leap year");
System.out.print("Enter a year XXXX (0 to quit): ");
year = scan.nextInt();
}
}
}