I'm trying to write a program using the switch() function such that when the user inputs 6 7 or 8, it returns "June", "July", and "August" respectively. When the user enters any other number between 1-12, it should return "Not summer", and any other input should return "Invalid". As shown in my code below, is there any way to express lines 16-24 in just one line?
int month;
cout << "Enter a number to determine what month it is: ";
cin >> month;
switch (month) {
case 6:
cout << "June";
break;
case 7:
cout << "July";
break;
case 8:
cout << "August";
break;
case 1:
case 2:
case 3:
case 4:
case 5:
case 9:
case 10:
case 11:
case 12:
cout << "Not summer";
break;
default:
cout << "Your input is out of range";
}