-
Notifications
You must be signed in to change notification settings - Fork 0
/
date.java
28 lines (28 loc) · 834 Bytes
/
date.java
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
# Java
class Day
{
void display(int year,int day)
{
String ar[] = {"January" , "February" , "March" , "April" , "May" , "June" , "July" , "August" , "September" , "October" , "November" , "December"};
int arr[] = {31 , 28 , 31 , 30 , 31 , 30 , 31 , 31 , 30 , 31 , 30 , 31};
String month = " ";
if(day <366)
{
for(int i = 0 ; i < 12 ;)
{
if(day - arr[i] < 0)
{
day = day;
month = ar[i];
break;
}
else
{
i++;
day = day - arr[i];
}
}
}
System.out.println(" the required date is " + " " + day + " th " + " " + month + " " + year);
}
}