PROBLEM 22
Easy

Salary After Tax

Programming Basics · JavaScript

</>
STATUS Not solved

TASK

Problem

#22

Given salary `salary` and tax percent `tax`, print take-home amount.

EXAMPLE

Example

Input
5000 13
Output
4350.0

LIMITS

Constraints

salary ≥ 0; 0 ≤ tax ≤ 100
📖
LEARN Theory for this problem
+

### Salary After Tax

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.', 'After each iteration, it should be clear what has already been accumulated and what remains to be processed.']

ANSWER Solution
+
const fs = require('fs');
const input = fs.readFileSync(0, 'utf8').trimEnd();
let [salary, tax] = input.trim().split(/\s+/).filter(Boolean).map(Number);
let result = (((salary) * (100 - tax)) / 100);
console.log(Number.isInteger(result) ? result.toFixed(1) : result);