Enum weekday from integer input

Report a typo
Hey there! This problem might be a bit unpredictable, but give it a go and let us know how you do!
Create an enum called Weekday with constants for MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY and SUNDAY. Each enum constant should have an associated integer value representing the day of the week (e.g., MONDAY=1, TUESDAY=2, etc.). Write a program that prompts the user to enter a day of the week as an integer (1-7) and prints the corresponding enum constant name.

Sample Input 1:

1

Sample Output 1:

MONDAY

Sample Input 2:

5

Sample Output 2:

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

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

int dayNumber = scanner.nextInt();

Weekday day = Weekday.values()[dayNumber - 1];
System.out.println(day);
}
}

enum Weekday {
// Define the enum constants here
}
___

Create a free account to access the full topic