Temperature Converter
Easy
27.9% Acceptance
Write a component called App
which accepts the temperature input in Celsius and converts it to Kelvin and Fahrenheit. Your component should have one input
JSX element of type number
that accepts input from the user.
Your component should return the following string in the p
JSX element, as indicated in the starting code:
{X}°C is {Y}°F and {Z}K.
Remember that X, Y and Z represent the temperature in Celsius, Fahrenheit and Kelvin respectively.
Use the formulas below for the conversions.
Celsius to Kelvin: K = C + 273.15
Celsius to Fahrenheit: F = (C * 9/5) + 32
We have already written some starting code for you.
Instructions
- Do not edit the
data-testid
attributes. - You should round any output numbers to 2 decimal points.
- Return the output string in the
p
element.
Hints
- Make sure you understand the formulas for converting temperatures from Celsius to Kelvin and Fahrenheit.
- Use the
useState
hook to store the temperature entered by the user in a state variable.