PHP: Celsius to Fahrenheit

Convert a temperature with floats and print it with a fixed number of decimals.

What to build

A program that converts Celsius to Fahrenheit.

Requirements

  • Read a temperature in Celsius (it may have decimals and may be negative).
  • Print the Fahrenheit value with exactly one decimal.

Input

One line: the temperature.

Output

One line.

Constraints

-100 ≤ C ≤ 100.

Example

Input:

100

Output:

212.0

Why it works

A cast to float lets the input have decimals, and %.1f rounds to one digit after the point.

Examples

Example 1 · Input
100
Expected output
212.0
Example 2 · Input
37
Expected output
98.6

Hints

Hint 1

The formula is F = C * 9 / 5 + 32.

Hint 2

printf("%.1f\n", $f) prints exactly one decimal.

Solution

Show one correct solution (try it yourself first)
<?php
$c = (float) trim(fgets(STDIN));
$f = $c * 9 / 5 + 32;
printf("%.1f\n", $f);

▶ Open this solution in the compiler

Lesson: Variables and types →