-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdate1.java
More file actions
79 lines (78 loc) · 1.66 KB
/
Copy pathdate1.java
File metadata and controls
79 lines (78 loc) · 1.66 KB
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package switchprograms;
import java.util.*;
public class date1
{
public static void main()
{
Scanner ob=new Scanner(System.in);
System.out.println("enter date between 1 to 31");
int d=ob.nextInt();
System.out.println("enter month");
int m=ob.nextInt();
System.out.println("enter year");
int y=ob.nextInt();String s="",s1="";int e;
switch(m)
{
case 1:
s="JAN";
break;
case 2:
s="FEB";
break;
case 3:
s="MAR";
break;
case 4:
s="APR";
break;
case 5:
s="MAY";
break;
case 6:
s="JUN";
break;
case 7:
s="JUL";
break;
case 8:
s="AUG";
break;
case 9:
s="SEP";
break;
case 10:
s="OCT";
break;
case 11:
s="NOV";
break;
case 12:
s="DEC";
break;
default:
System.out.println("WRONG CHOICE");
}
if(d>=11&&d<=20||d>=24&&d<=30||d>=4&&d<=10)
{
s1="th";
}
else
{ e=d%10;
if(e==1)
{
s1="st";
}
else if(e==2)
{
s1="nd";
}
else if(e==3)
{
s1="rd";
}
else
{}
}
System.out.println(d+s1+" "+s+" "+y);
}
}