PROBLEM 78
Medium

Ticket Price by Age

Programming Basics · C#

</>
STATUS Not solved

TASK

Problem

#78

Given an age, print ticket price 0 for age below 6, 50 for age 6..17, and 100 for age 18 or older. Print only the required answer; do not print prompts, labels, or debug text.

EXAMPLE

Example

Input
5
Output
0

LIMITS

Constraints

- Every token parsed with `int.Parse` is a valid 32-bit signed integer; test data avoid unintended overflow in the task's intended calculation.
- Input is syntactically valid for the task except where invalid input is deliberately being tested (for example a `TryParse`/validation exercise).
- Print only the required answer; do not add prompts, labels, debug text, or extra spaces/lines.
📖
LEARN Theory for this problem
+

Piecewise formulas are best expressed as clear, exhaustive branches. Check branch boundaries carefully so every input follows exactly one intended rule. For **Ticket Price by Age**, the concrete requirement is: Given an age, print ticket price 0 for age below 6, 50 for age 6..17, and 100 for age 18 or older. Keep input parsing, the core operation, and output formatting separate so each part can be checked independently. Before coding, trace the first example by hand and identify the smallest valid or boundary-shaped input; this exposes off-by-one, sign, empty/single-element, and formatting mistakes before they reach the implementation.

💡
NEED HELP? Hints
+

['Piecewise formulas are best expressed as clear, exhaustive branches. Check branch boundaries carefully so every input follows exactly one intended rule.', 'Before coding, state this exact input-to-output rule: Given an age, print ticket price 0 for age below 6, 50 for age 6..17, and 100 for age 18 or older.', 'Trace the public example by hand, then test the smallest input and the edge case most likely to change an index, branch, tie, or empty result.']

ANSWER Solution
+
using System;
class Program
{
    static void Main()
    {
        int age=int.Parse(Console.ReadLine());
        int result=age<6?0:(age<18?50:100);
        Console.WriteLine(result);
    }
}