← Unit 2 · all exercises
Saved in this browser only

Ticket price by age

Under 5 is free, so return 0. Under 18 is a child ticket at 800. From 65 upward is a senior ticket at 900. Everyone else pays 1200. Prices are in cents.

int price(int age)

Solution.java
Loading editor…
Results

Examples

  • price(10) → 800
  • price(30) → 1200

There are also 6 hidden tests you can't see. Solve the problem, not the examples.