@@ -67,10 +67,12 @@ private DateRepresentation() {
6767 suffix = "" ;
6868 oldDate = 0 ;
6969 daysAfter = 0 ;
70- monthNames = new String []{"JANUARY" , "FEBRUARY" , "MARCH" ,
71- "APRIL" , "MAY" , "JUNE" , "JULY" , "AUGUST" , "SEPTEMBER" ,
72- "OCTOBER" , "NOVEMBER" , "DECEMBER" };
73- monthDays = new int []{31 , 28 , 31 , 30 , 31 , 30 , 31 , 31 , 30 , 31 , 30 , 31 };
70+ monthNames = new String []{"JANUARY" , "FEBRUARY" ,
71+ "MARCH" , "APRIL" , "MAY" , "JUNE" , "JULY" ,
72+ "AUGUST" , "SEPTEMBER" , "OCTOBER" , "NOVEMBER" ,
73+ "DECEMBER" };
74+ monthDays = new int []{31 , 28 , 31 , 30 , 31 , 30 , 31 , 31 ,
75+ 30 , 31 , 30 , 31 };
7476 }
7577
7678 /**
@@ -83,13 +85,14 @@ private void input() {
8385 System .out .print ("Enter year(4 digits): " );
8486 year = Integer .parseInt (sc .next ());
8587 if (year < 1000 || year > 9999 ) {
86- System .out .println ("Try again! Year must be of 4 digits." );
88+ System .out .println ("Try again! " +
89+ "Year must be 4 digits." );
8790 input ();
8891 }
8992 System .out .print ("Enter increment after old date: " );
9093 increment = Integer .parseInt (sc .next ());
9194 if (increment < 1 || increment > 100 ) {
92- System .out .println ("Try again! Range is 1 to 100." );
95+ System .out .println ("Try again! Range 1 to 100." );
9396 input ();
9497 }
9598 }
@@ -99,7 +102,8 @@ private void input() {
99102 */
100103 private void oldDateCalculator () {
101104 //February should have 29 days if it is leap year
102- if (year % 400 == 0 || (year % 100 != 0 && year % 4 == 0 ))
105+ if (year % 400 == 0 ||
106+ (year % 100 != 0 && year % 4 == 0 ))
103107 monthDays [1 ] = 29 ;
104108
105109 oldDate = days ;
@@ -111,7 +115,8 @@ private void oldDateCalculator() {
111115 if (i == 12 ) {
112116 i = 0 ;
113117 year ++;
114- if (year % 400 == 0 || (year % 100 != 0 && year % 4 == 0 )) {
118+ if (year % 400 == 0 ||
119+ (year % 100 != 0 && year % 4 == 0 )) {
115120 monthDays [1 ] = 29 ;
116121 }
117122 }
@@ -143,19 +148,23 @@ private void newDateCalculator() {
143148 if (i == 12 ) {
144149 i = 0 ;
145150 year ++;
146- if (year % 400 == 0 || (year % 100 != 0 && year % 4 == 0 )) {
151+ if (year % 400 == 0 ||
152+ (year % 100 != 0 && year % 4 == 0 )) {
147153 monthDays [1 ] = 29 ;
148154 }
149155 }
150156 }
151157 //Adding suffix as per day
152158 if (daysAfter % 10 == 1 && daysAfter / 10 != 1 ) {
153159 suffix = "ST" ;
154- } else if (daysAfter % 10 == 2 && daysAfter / 10 != 1 ) {
160+ }
161+ else if (daysAfter % 10 == 2 && daysAfter / 10 != 1 ) {
155162 suffix = "ND" ;
156- } else if (daysAfter % 10 == 3 && daysAfter / 10 != 1 ) {
163+ }
164+ else if (daysAfter % 10 == 3 && daysAfter / 10 != 1 ) {
157165 suffix = "RD" ;
158- } else {
166+ }
167+ else {
159168 suffix = "TH" ;
160169 }
161170 }
@@ -168,10 +177,12 @@ public static void main(String[] args) {
168177 DateRepresentation ob = new DateRepresentation ();
169178 ob .input ();
170179 ob .oldDateCalculator ();
171- System .out .println ("Old date: " + ob .oldDate + ob .suffix + " " +
172- ob .monthNames [ob .monthIndex ] + " " + ob .year );
180+ System .out .println ("Old date: " + ob .oldDate +
181+ ob .suffix + " " + ob .monthNames [ob .monthIndex ]
182+ + " " + ob .year );
173183 ob .newDateCalculator ();
174- System .out .println ("New date: " + ob .daysAfter + ob .suffix + " " +
175- ob .monthNames [ob .monthIndex ] + " " + ob .year );
184+ System .out .println ("New date: " + ob .daysAfter +
185+ ob .suffix + " " + ob .monthNames [ob .monthIndex ]
186+ + " " + ob .year );
176187 }
177188}
0 commit comments