Challenge: Weekday or Weekend

Lab Java Beginner 10 points

Write an enum Day with MON, TUE, WED, THU, FRI, SAT, SUN. Read a day name in capitals, turn it into a Day with valueOf, and print <DAY> is day <n> and a <weekday/weekend>, where n starts at 1 for MON.

Input

One word, e.g. SAT.

Output

For SAT: SAT is day 6 and a weekend

Example

Input

SAT

Output

SAT is day 6 and a weekend
Sample input available Sample output available
Editor
Java

Hints

Day.valueOf("SAT") gives Day.SAT.

ordinal() starts at 0, so add 1.

You can compare enum values with ==.

Solution explanation

Enum values are unique objects, so == is the right way to compare them.

Show solution
import java.util.Scanner;

enum Day {
    MON, TUE, WED, THU, FRI, SAT, SUN
}

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Day d = Day.valueOf(sc.next());
        String kind = (d == Day.SAT || d == Day.SUN) ? "weekend" : "weekday";
        System.out.println(d + " is day " + (d.ordinal() + 1) + " and a " + kind);
    }
}
Output
Answer
HOME LABS COMMUNITY DASHBOARD