Given an input integer representing a temperature in Celsius, print the equivalent temperature in Fahrenheit as an integer value. To convert from Celsius to Fahrenheit, multiply the Celsius value by 9, divide by 5, and add 32.
Properties of basic types
Converting Celsius to Fahrenheit
Report a typo
Sample Input 1:
0Sample Output 1:
32Sample Input 2:
100Sample Output 2:
212Write a program in Kotlin
import kotlin.math.round
fun main() {
// Read temperature in Celsius as a double
val celsius = readLine()!!.toDouble()
// TODO: Convert Celsius to Fahrenheit
val fahrenheit = 0.0
// Print temperature in Fahrenheit rounded to nearest integer
println(round(fahrenheit).toInt())
}
Create a free account to access the full topic
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.