PROBLEM 14
Easy

Celsius to Fahrenheit

Programming Basics · JavaScript

</>
STATUS Not solved

TASK

Problem

#14

Given Celsius temperature `c`, convert it to Fahrenheit using `F = C * 9 / 5 + 32`.

EXAMPLE

Example

Input
25
Output
77.0

LIMITS

Constraints

c ≥ -273.15
📖
LEARN Theory for this problem
+

### Celsius to Fahrenheit

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.', '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 celsius = Number(fs.readFileSync(0, 'utf8').trim());
const fahrenheit = celsius * 9 / 5 + 32;

console.log(Number.isInteger(fahrenheit) ? fahrenheit.toFixed(1) : fahrenheit);