-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathYear.java
More file actions
40 lines (39 loc) · 716 Bytes
/
Copy pathYear.java
File metadata and controls
40 lines (39 loc) · 716 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
34
35
36
37
38
39
40
import java.util.Scanner;
class leapyear1
{
int year;
void set_year(int n)
{
year=n;
}
}
class leapyear2 extends leapyear1
{
String res;
void find()
{
if(year%4==0)
res="leap year";
else
res="non leap year";
}
}
class leapyear3 extends leapyear2{
void display()
{
System.out.println("the year"+year+"is"+res);
}
}
public class Year {
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
int p;
System.out.println("enter an year");
p=sc.nextInt();
leapyear3 s = new leapyear3();
s.set_year(p);
s.find();
s.display();
}
}