/// Returns the ticket price in dollars for a customer of the given age.
int basePrice(int age) {
    if (age < 5) {
        return 0;
    } else if (age <= 12) {
        return 8;
    } else if (age <= 64) {
        return 14;
    } else {
        return 10;
    }
}

/// Returns the price after any day-of-week discount.
int applyDiscount(int price, String day) {
    if (day.equals("tuesday") && price > 0) {
        return price - 3;
    }
    return price;
}

/// Returns the final ticket price for an age and day.
int ticketPrice(int age, String day) {
    return applyDiscount(basePrice(age), day);
}

void main() {
    IO.println(ticketPrice(70, "tuesday"));
    IO.println(ticketPrice(3, "tuesday"));
    IO.println(ticketPrice(30, "friday"));
}

// From Groundwork, chapter 6 (ch06-methods), box 16.
// This example is from Groundwork, licensed CC BY-NC-SA 4.0.
// Run with: java ch06_16.java
