Created
October 27, 2020 14:35
-
-
Save NishantMishra-1/c0251ef709ca068180af57073b955525 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Created by IntelliJ IDEA. | |
* Author: Nishant Mishra (NishantMishra-1) | |
* Date: 27-10-2020 | |
* Time: 18:07 | |
* File: LabTask.java | |
*/ | |
package JavaEnumTask; | |
import java.util.Calendar; | |
import java.util.GregorianCalendar; | |
enum months { | |
JANUARY(31), | |
FEBRUARY(28), | |
MARCH(31), | |
APRIL(30), | |
MAY(31), | |
JUNE(30), | |
JULY(31), | |
AUGUST(31), | |
SEPTEMBER(30), | |
OCTOBER(31), | |
NOVEMBER(30), | |
DECEMBER(31); | |
private final int numberOfDay; | |
months(int numberOfDay) { | |
this.numberOfDay = numberOfDay; | |
} | |
public int getNumberOfDay() { | |
return numberOfDay; | |
} | |
} | |
public class LabTask { | |
public static void main(String[] args) { | |
int currentDay = new GregorianCalendar().get(Calendar.DAY_OF_MONTH); | |
int presentMonth = new GregorianCalendar().get(Calendar.MONTH); | |
String[] calender = {"JANUARY", "FEBRUARY", "MARCH", "APRIL", "MAY", "JUNE", "JULY", "AUGUST", "SEPTEMBER", "OCTOBER", "NOVEMBER", "DECEMBER"}; | |
months currentMonth = months.valueOf(calender[presentMonth]); | |
switch (currentMonth) { | |
case JANUARY: | |
System.out.println(currentMonth.getNumberOfDay() - currentDay + " Days left in " + currentMonth + "!"); | |
break; | |
case FEBRUARY: | |
System.out.println(currentMonth.getNumberOfDay() - currentDay + " Days left in " + currentMonth + "!"); | |
break; | |
case MARCH: | |
System.out.println(currentMonth.getNumberOfDay() - currentDay + " Days left in " + currentMonth + "!"); | |
break; | |
case APRIL: | |
System.out.println(currentMonth.getNumberOfDay() - currentDay + " Days left in " + currentMonth + "!"); | |
break; | |
case MAY: | |
System.out.println(currentMonth.getNumberOfDay() - currentDay + " Days left in " + currentMonth + "!"); | |
break; | |
case JUNE: | |
System.out.println(currentMonth.getNumberOfDay() - currentDay + " Days left in " + currentMonth + "!"); | |
break; | |
case JULY: | |
System.out.println(currentMonth.getNumberOfDay() - currentDay + " Days left in " + currentMonth + "!"); | |
break; | |
case AUGUST: | |
System.out.println(currentMonth.getNumberOfDay() - currentDay + " Days left in " + currentMonth + "!"); | |
break; | |
case SEPTEMBER: | |
System.out.println(currentMonth.getNumberOfDay() - currentDay + " Days left in " + currentMonth + "!"); | |
break; | |
case OCTOBER: | |
System.out.println(currentMonth.getNumberOfDay() - currentDay + " Days left in " + currentMonth + "!"); | |
break; | |
case NOVEMBER: | |
System.out.println(currentMonth.getNumberOfDay() - currentDay + " Days left in " + currentMonth + "!"); | |
break; | |
case DECEMBER: | |
System.out.println(currentMonth.getNumberOfDay() - currentDay + " Days left in " + currentMonth + "!"); | |
break; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment