-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtask2 iii.java
More file actions
33 lines (29 loc) · 817 Bytes
/
task2 iii.java
File metadata and controls
33 lines (29 loc) · 817 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
32
33
// a program that check if the year is a leap year
package leap.year;
//importing scanner
import java.util.Scanner;
public class LeapYear {
//declaring variables
static int year;
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
// enter year
System.out.println("enter any year");
year =input.nextInt();
boolean flag=false;
if (year % 400==0){
flag=true;
}
else if (year % 100==0){
flag=false;
}
else flag=year % 4==0;
if(flag){
System.out.println("year"+year+" is a leap year");
}
else
{
System.out.println("year"+year+" is not a leap year");
}
}
}