PROBLEM 93
Hard

ATM

Programming Basics · JavaScript

</>
STATUS Not solved

TASK

Problem

#93

Given `balance`, withdrawal `amount`, and remaining daily `limit`. Approve if amount is positive, divisible by 100, and does not exceed both balance and limit.

EXAMPLE

Example

Input
10000 2500 5000
Output
APPROVED

LIMITS

Constraints

All numeric input values fit in JavaScript `Number`.
📖
LEARN Theory for this problem
+

### ATM

`if / else if / else` chooses a branch from boolean conditions. Comparisons such as `<`, `>=`, `===` and logical operators `&&`, `||`, `!` combine the exact rules that decide which output is valid.

💡
NEED HELP? Hints
+

['Translate every case from the statement into a boolean condition before writing branches.', 'Verify the accumulator initial value and both loop boundaries; this is where off-by-one errors most often appear.']

ANSWER Solution
+
const fs = require('fs');

const [balance, amount, limit] = fs
    .readFileSync(0, 'utf8')
    .trim()
    .split(/\s+/)
    .map(Number);

const approved =
    amount > 0 &&
    amount % 100 === 0 &&
    amount <= balance &&
    amount <= limit;

console.log(approved ? 'APPROVED' : 'DECLINED');