Nested If: Ticket Price
Problem Description
In this problem, you will create a program that receives age and a student flag as input, determines the ticket price across 4 patterns using nested if statements, and displays the result to standard output.
Nested If: Ticket Price
Learning Objectives
Bloom Level: Apply
Practical Goals
- Implement 2-axis conditional branching with nested if statements
- Set boundary value (18 years) condition correctly
- Use boolean variable directly in condition expression
- Express 4-pattern fee calculation in structured code
Real-World Scenario
Scenario Type: Business
Business Context
You are developing a movie theater ticket sales system. You implement a "2-axis discount system" where prices vary by age and student ID presence.
This system is used in amusement parks, transportation, sports facilities, and many services. Master the pattern of determining fees from combinations of age category and attribute category.
Why This Matters
- Fee calculation is a basic function of many business systems
- 2-axis conditional branching is a frequent pattern in practice
- Accurate boundary value processing prevents billing errors
Problem Statement
Create a program that receives age and student status as input, then determines the ticket price using nested if statements.
Rules:
- Age 18+: 1500 yen for students, 2000 yen for general
- Under 18: 1000 yen for students, 1200 yen for general
Input
Line 1: Age (integer)
Line 2: Student flag (true=student, false=general)
Output
Age: [age] years old
Student: [status]
Ticket price: [price] yen
Ready to Try Running Code?
Log in to access the code editor and execute your solutions for this problem.
Don't have an account?
Sign Up