Program to convert temperature from Fahrenheit to Celsius in Kotlin
package com.includehelp
import java.util.*
//Main Function , Entry point of Program
fun main(args: Array<String>) {
//Input Stream
val scanner = Scanner(System.`in`)
//Input temperature in Fahrenheit
print("Enter temperature into Fahrenheit : ")
val fahrenheit = scanner.nextDouble()
//Convert Fahrenheit to Celsius
val celsius =( (fahrenheit - 32 ) * 5)/9
//Print temperature in Celsius
println("Temperature in Fahrenheit ($fahrenheit) = Celsius ($celsius)")
}
Output
Output will be:
Run 1:
Enter temperature into Fahrenheit : 67
Temperature in Fahrenheit (67.0) = Celsius (19.444444444444443)
---
Run 2:
Enter temperature into Fahrenheit : 78
Temperature in Fahrenheit (78.0) = Celsius (25.555555555555557)
Program to convert temperature from Fahrenheit to Celsius in Kotlin
Output
need an explanation for this answer? contact us directly to get an explanation for this answer