All challenges
Easy 0 solved 0% acceptance

Ticket Price by Age

Choose a cinema ticket price from the visitor's age.

Problem

A cinema charges by age: children under 3 are free, ages 3–12 pay 5, ages 13–64 pay 12, and 65 or older pay 7.

Implement ticket_price(age).

Input

age: The visitor's age in years.

Output

Return the ticket price.

Constraints

0 ≤ age ≤ 120

Examples

Example 1
Input:
age = 10

Expected output:
expected = 5
Input:
long long age = 10;

Expected output:
long long expected = 5;
Input:
long age = 10;

Expected output:
long expected = 5;

Explanation

10 is between 3 and 12, so the price is 5.

Example 2
Input:
age = 70

Expected output:
expected = 7
Input:
long long age = 70;

Expected output:
long long expected = 7;
Input:
long age = 70;

Expected output:
long expected = 7;

Explanation

70 is 65 or older, so the senior price of 7 applies.

References

This challenge is adapted for CodeUtility. Follow the statement and constraints above.

Learn from others

Community solutions

No published solutions yet. Solve this challenge to share the first one.