Here is a Java Program to Display Season using Switch Statement. This is an improved version of this Java Program.
Output of Above Java Program
April is in the Spring.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | class Switch { public static void main(String args[]) { int month = 4 ; String season; switch (month) { case 12 : case 1 : case 2 : season = "Winter" ; break ; case 3 : case 4 : case 5 : season = "Spring" ; break ; case 6 : case 7 : case 8 : season = "Summer" ; break ; case 9 : case 10 : case 11 : season = "Autumn" ; break ; default : season = "Bogus Month" ; } System.out.println( "April is in the " + season + "." ); } } |
Output of Above Java Program
April is in the Spring.