Determine Movie Ticket Cost by Age Conditional Logic Guide

Discover the perfect movie ticket price based on age with our easy-to-use

Technique:
Workflow Stage:
Use Case
Save Prompt
Prompt Saved

Overview

This prompt aims to guide programmers in creating conditional statements for determining movie ticket prices based on age. Beginners and educators in programming will benefit from this structured exercise.

Prompt Overview

Purpose: This code determines movie ticket prices based on age categories.
Audience: It is intended for programmers learning conditional statements in coding.
Distinctive Feature: The program uses clear conditional logic to handle multiple age ranges efficiently.
Outcome: Users receive accurate ticket pricing information based on their age input.

Quick Specs

Variables to Fill

  • [age_value] – Age Value
  • [cost] – Cost

Example Variables Block

  • [age_value]: Example Age Value
  • [cost]: Example Cost

The Prompt


Create a series of conditional statements to determine and print the cost of a movie theater ticket based on an age variable. The conditions are:
– Children under 4 years old: “Free”
– Children between 4 and 12 years old (inclusive): “$5”
– Teenagers between 13 and 19 years old (inclusive), and senior citizens aged 65 and above: “$10”
– Adults between 20 and 64 years old (inclusive): “$15”
For each specified age, the output format should include the age followed by the corresponding ticket cost. Maintain correct capitalization, as different cases will be interpreted differently by the computer.
# Steps
1. Define a variable `age` for each test case.
2. Use conditional statements (if-else) to check the age against specified conditions.
3. Print the age followed by the corresponding cost based on age.
4. Repeat for all test cases.
# Output Format
The output should be in the following format:
“`
Age: [age_value]
[cost]
“`
Where:
– `[age_value]` is the age being tested
– `[cost]` is the corresponding ticket price as specified in the conditions.
# Examples
5. Input: `age = 1`
Output:
“`
Age: 1
Free
“`
6. Input: `age = 12`
Output:
“`
Age: 12
$5
“`
7. Input: `age = 15`
Output:
“`
Age: 15
$10
“`
Repeat this pattern for each age indicated:
– 1, 3, 4, 12, 13, 19, 20, 50, 65, and 80.
# Notes
– Ensure that each condition properly uses logical operators to capture the correct age range.
– Remember that capitalization matters when outputting text.
– Use clear and efficient conditional logic to minimize code redundancy.

Screenshot Examples

How to Use This Prompt

  1. [age]: variable representing the person’s age.
  2. [cost]: ticket price based on age category.
  3. [age < 4]: condition for free tickets.
  4. [age >= 4 && age <= 12]: condition for $5 tickets.
  5. [age >= 13 && age <= 19]: condition for $10 tickets (teenagers).
  6. [age >= 65]: condition for $10 tickets (senior citizens).
  7. [age >= 20 && age <= 64]: condition for $15 tickets (adults).
  8. [print]: outputs the age and corresponding cost.

Tips for Best Results

  • Free for toddlers: Children under 4 years old get in for free.
  • Affordable for kids: Children between 4 and 12 years old pay only $5.
  • Teen and senior pricing: Teenagers aged 13-19 and seniors 65+ pay $10.
  • Adult ticket cost: Adults aged 20-64 pay $15 for their tickets.

FAQ

  • What is the ticket cost for a 1 year old?
    Age: 1
    Free
  • How much for a 12 year old ticket?
    Age: 12
    $5
  • What is the cost for a 15 year old?
    Age: 15
    $10
  • What is the ticket price for an 80 year old?
    Age: 80
    $10

Compliance and Best Practices

  • Best Practice: Review AI output for accuracy and relevance before use.
  • Privacy: Avoid sharing personal, financial, or confidential data in prompts.
  • Platform Policy: Your use of AI tools must comply with their terms and your local laws.

Revision History

  • Version 1.0 (February 2026): Initial release.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Used Prompts

Related articles

Improve financial management app code quality and robustness

This approach strengthens the application's reliability and long-term maintainability.

Prevent simultaneous boss menu activation conflicts.

Ensure stable and independent menu interactions for a seamless user experience.

C Code Compilation Error Analysis for Developers

Enhance your debugging skills by understanding C code compilation errors.

C Interface Analysis and Explanation for Developers

Enhance your coding skills by mastering C# interface analysis techniques.