// Calculates a movie ticket price from age and day of the week.

void main() {
    String ageText = IO.readln("Customer age: ");

    try {
        int age = Integer.parseInt(ageText.strip());

        if (age < 0 || age > 120) {
            IO.println("Please enter a realistic age.");
        } else {
            String day = IO.readln("Day of the week: ").strip().toLowerCase();

            int price;
            String category;
            if (age < 5) {
                price = 0;
                category = "Infant";
            } else if (age <= 12) {
                price = 8;
                category = "Child";
            } else if (age <= 64) {
                price = 14;
                category = "Adult";
            } else {
                price = 10;
                category = "Senior";
            }

            int discount = 0;
            if (day.equals("tuesday") && price > 0) {
                discount = 3;
                price -= discount;
            }

            IO.println();
            IO.println("Category: " + category);
            if (discount > 0) {
                IO.println("Tuesday discount: -$" + discount);
            }
            IO.println("Price: $" + price);
        }
    } catch (NumberFormatException e) {
        IO.println("Age must be a whole number.");
    }
}

// From Groundwork, chapter 4 (ch04-making-decisions), box 19.
// This example is from Groundwork, licensed CC BY-NC-SA 4.0.
// Run with: java ch04_19.java
