Question: Define an enum called Season with four values: WINTER, SPRING, SUMMER, and AUTUMN. Create a switch statement that takes a Season type variable, and prints

Define an enum called Season with four values: WINTER, SPRING, SUMMER, and AUTUMN.
Create a switch statement that takes a Season type variable, and prints a description of the typical weather and activities for that season.
The Season enum defines the four seasons.
expected output for calling the program with a WINTER, SPRING, SUMMER and AUTUMN values.
For winter print: It's cold and snowy. Time for skiing and drinking hot chocolate!
For Spring print: Flowers are blooming. A great time for hiking and enjoying nature! It's hot and sunny.
For Summer print: Perfect for going to the beach or having a barbecue!
For Autumn print: Leaves are falling. Enjoy the cool breeze and go for a walk in the park!
There is no need for an input statement. You can assign a value to the enum variable or if you want to do research on Random in Java, you can assign a random season to the Season variable.
_______________________________________________________
here is an example program that uses enum and switch:
public class Main
{
// Define the enum
public enum TrafficLight { RED, YELLOW, GREEN; }
// Main method to test the switch statement
public static void main(String[] args)
{
TrafficLight light;
// create a variable of type TrafficLight enum
light = TrafficLight.YELLOW;
switch (light)
{
case RED:
System.out.println("Stop");
break;
case YELLOW:
System.out.println("Slow down");
break;
case GREEN:
System.out.println("Go");
break;
default:
System.out.println("Invalid light");
}//switch
}// main
}//Main

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!