PROBLEM 20
Easy

Distance from Speed and Time

Programming Basics · JavaScript

</>
STATUS Not solved

TASK

Problem

#20

Given speed `v` and time `t`, print distance traveled.

EXAMPLE

Example

Input
60 2.5
Output
150.0

LIMITS

Constraints

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

### Distance from Speed and Time

Integer division separates higher decimal/time units, while `%` returns the remainder. These two operations let a program isolate digits or split a total number of seconds/minutes into components.

💡
NEED HELP? Hints
+

['Decide which part comes from division and which part comes from the remainder.', 'Before printing, output only the computed result and do not add explanatory text that is absent from the required format.']

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