I'm learning java and I got stuck at a question where I need to enter the days of the week into an enum. I then need to put several responses into a switch case statement and have a user enter the day of the week into a JOptionPane and get the program to output the appropriate response.
This is my Enum:
public enum Day {
SUNDAY, MONDAY, TUESDAY, WEDNESDAY,THURSDAY, FRIDAY, SATURDAY;
}
This is my attempt at getting the correct response:
public class enumDayMood {
Day day;
public static void main(String[] args){
String day = JOptionPane.showInputDialog("Enter the day of the week.");
}
public void telDayMood(){
Day day = Day.MONDAY;
switch(day){
case MONDAY:
JOptionPane.showMessageDialog(null,"Mondays are bad.");
break;
case FRIDAY:
JOptionPane.showMessageDialog(null,"Fridays are better.");
break;
case SATURDAY: case SUNDAY:
JOptionPane.showMessageDialog(null,"Weekends are best");
break;
default:
JOptionPane.showMessageDialog(null,"Midweek days are so-so.");
break;
}
}
}
I was able to output every day of the week individually but I can't seem to get the user input to work. I've tried multiple methods but none seem to work.