PROBLEM 70
Medium

Bank Interest

Programming Basics · JavaScript

</>
STATUS Not solved

TASK

Problem

#70

Given deposit `amount` and annual rate `rate` percent, print the amount after one year.

EXAMPLE

Example

Input
10000 5
Output
10500.0

LIMITS

Constraints

amount ≥ 0; 0 ≤ rate ≤ 100
📖
LEARN Theory for this problem
+

### Bank Interest

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