class Switch
{
	public static void main(String args[ ])
	{
		String season;
		int month =10;
		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(month+" Month is in the " + season +".");
	}
}

Recommended Answers

All 2 Replies

You need to use Scanner to scan for input from the console. Should be a quick google search.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.