PROBLEM 69
Medium

Ticket Price

Programming Basics · JavaScript

</>
STATUS Not solved

TASK

Problem

#69

Given passenger age: ticket costs 0 under 6, 50 for 6–17, 100 for 18–64, and 60 for 65+.

EXAMPLE

Example

Input
70
Output
60

LIMITS

Constraints

0 ≤ age ≤ 120
📖
LEARN Theory for this problem
+

### Ticket Price

JavaScript arithmetic works with numeric values stored in variables. A clear solution reads the needed values, computes the formula with `+`, `-`, `*`, `/` or `**`, and prints only the final result.

💡
NEED HELP? Hints
+

['Write the formula using named intermediate values if it contains more than one operation.', 'Separate input parsing, result computation, and output into distinct steps so errors are easier to spot.']

ANSWER Solution
+
const fs = require('fs');
const input = fs.readFileSync(0, 'utf8').trimEnd();
let a = Number(input);
if (a < 6) {
    console.log(0);
} else {
    if (a < 18) {
        console.log(50);
    } else {
        if (a < 65) {
            console.log(100);
        } else {
            console.log(60);
        }
    }
}