Answer to Question #232992 in Java | JSP | JSF for Siya

Question #232992

Design a program using Java NetBeans (Console application). With the following enum class: public enum Day { SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY } Create a second class called enumDayMood with a void method call telDayMood (). This method contain a switch case as follows


1
Expert's answer
2021-09-03T14:05:46-0400
import javax.swing.JOptionPane;


enum Day {
	SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY
}


class enumDayMood {
	void telDayMood(Day day) {
		
		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;
		}


	}


}


public class DayMoodApp {
	public static void main(String[] args) {
		enumDayMood enumDayMood=new enumDayMood();
		enumDayMood.telDayMood(Day.SATURDAY);
		enumDayMood.telDayMood(Day.FRIDAY);
		enumDayMood.telDayMood(Day.TUESDAY);
		enumDayMood.telDayMood(Day.MONDAY);
	}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS