39. JAVA Program To Check Seasons Using Switch Case.
How does this program work?
- In this program you are going to learn about How to check switch case in Java.
Here is the code
public class seasons
{
public static void main(String args[] )
{
String season;
System.out.println("Enter any month(1 to 12)");
Scanner obj = new Scanner(System.in);
int entry = obj.nextInt();
switch (entry)
{
case 12:
case 1:
season = "Winter";
break;
case 2:
case 3:
season = "Spring";
break;
case 4:
case 5:
case 6:
season = "Summer";
break;
case 7:
case 8:
season = "Monsoon";
break;
default:
season = "Autumn";
}
System.out.println("The Entered month is in the " + season + ".");
}
}