PROBLEM 12
Easy

Price After Discount

Programming Basics · JavaScript

</>
STATUS Not solved

TASK

Problem

#12

Given `price` and percentage `discount`, print the price after discount.

EXAMPLE

Example

Input
1000 15
Output
850.0

LIMITS

Constraints

0 ≤ discount ≤ 100
📖
LEARN Theory for this problem
+

### Price After Discount

`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.', '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 [price, discount] = input.trim().split(/\s+/).filter(Boolean).map(Number);
let result = (((price) * (100 - discount)) / 100);
console.log(Number.isInteger(result) ? result.toFixed(1) : result);