Ticket Pricing System - Problem
You are building a movie ticket pricing system that calculates the correct ticket price based on age and day of the week.
Pricing Rules:
- Child (age < 12):
$5 - Adult (age 12-59):
$10 - Senior (age 60+):
$7
Weekend Surcharge: Add $3 to the base price if isWeekend is true.
Given a person's age and whether it's a weekend, return the total ticket price.
Input & Output
Example 1 — Child Weekend
$
Input:
age = 8, isWeekend = true
›
Output:
8
💡 Note:
Age 8 is a child (< 12), so base price is $5. Weekend adds $3 surcharge. Total: $5 + $3 = $8
Example 2 — Adult Weekday
$
Input:
age = 25, isWeekend = false
›
Output:
10
💡 Note:
Age 25 is adult (12-59), so base price is $10. No weekend surcharge. Total: $10
Example 3 — Senior Weekend
$
Input:
age = 65, isWeekend = true
›
Output:
10
💡 Note:
Age 65 is senior (60+), so base price is $7. Weekend adds $3 surcharge. Total: $7 + $3 = $10
Constraints
- 0 ≤ age ≤ 150
- isWeekend is either true or false
Visualization
Tap to expand
💡
Explanation
AI Ready
💡 Suggestion
Tab
to accept
Esc
to dismiss
// Output will appear here after running code