Displaying month name based on its number

Report a typo

You've been given several lines of Java code that is out of order. The resultant program, when correctly ordered, should be able to display the name of the month based on the numeric value of the month given, using a switch statement. If the month number is out of range, it will return 'Invalid month'. Your task is to reorganize the given lines for proper execution of this task. Keep in mind, the output of the main method should be 'February'.

Reorder lines using drag or arrows. Adjust indentation with left buttons
                System.out.println(getMonthName(month));
              
                public static void main(String[] args) {
              
                case 1: return "January";
              
                public class Main {
              
                case 2: return "February";
              
                }
              
                }
              
                default: return "Invalid month";
              
                }
              
                switch (monthNumber) {
              
                }
              
                private static String getMonthName(int monthNumber) {
              
                int month = 2;
              

Create a free account to access the full topic