Printing the month name for the month number
As you have probably noticed, there is a lot of repetition which we can take advantage of. We can declare an array containing all the string representations of the months like so.

String[] months = {"January", "February", "March", ..., "December"};


Once you have that, we can simply do:

if (num &gt;= 1 &amp;&amp; num &lt;= 12) {
    System.out.format("The name of month number %d is %s\n", num, months[num-1]);
} else {
    System.out.println("You have entered an invalid number");
}


Edit: sorry, just saw the bit about "by still using the switch statement". I'll still leave this here though because I think it's a better solution than a switch statement.

If you really insist on using the switch (but you shouldn't),
then you can at least extract the repeated string part and formatting logic to a helper method:

private static void printMonth(int num, String name) {
    System.out.printf("The name of month number %d is %s%n", num, name);
}


And then rewrite the switch using that method:

switch (num)
{
case 1:
    printMonth(num, "January");
    break;
case 2:
    printMonth(num, "February");
    break;
// .... and so on


But really, insisting on a switch here is forced,
and goes against good practices.