-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDate.java
More file actions
55 lines (38 loc) · 933 Bytes
/
Date.java
File metadata and controls
55 lines (38 loc) · 933 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/*9:Create Date class with data members day,month,year.create getter setter for data members.
Write display function to display date. */
import java.util.Scanner;
public class Date {
private int day,year;
String month;
Scanner input = new Scanner(System.in);
public int getDay() {
return day;
}
public String getMonth() {
return month;
}
public int getYear() {
return year;
}
public void setDay(int day) {
this.day = day;
}
public void setMonth(String month) {
this.month = month;
}
public void setYear(int year) {
this.year = year;
}
public void displayDate() {
System.out.println("Date : "+day+"/"+month+"/"+year);
}
public static void main(String[] args) {
Date d1 = new Date();
d1.setDay(2);
d1.setMonth("June");
d1.setYear(2020);
System.out.println(d1.getDay()+" / "+d1.getMonth()+" / "+d1.getYear());
System.out.println();
d1.displayDate();
}
}