Months of the year

Report a typo

Write a program that reads the number of the month (1-6) and outputs the name. Please use the switch expression in this task.

  1. January

  2. February

  3. March

  4. April

  5. May

  6. June

If a number does not belong to any of the listed months, the program should output error!.

Example:

Input

1

Output

January

Note: the output text should exactly match the sample, including the letters' case.

Sample Input 1:

1

Sample Output 1:

January
Write a program in Java 17
import java.util.Scanner;

class Main {

public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);

// write your code here
}
}
___

Create a free account to access the full topic