java转换 kotlin

Given temperature in Fahrenheit, we have to convert it into Celsius

给定华氏温度,我们必须将其转换为摄氏温度

Example:

例:

    Input:
    Fahrenheit = 67

    Output:
    Celsius = 19.444444444444443

将温度从华氏温度转换为摄氏温度的程序 (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)


翻译自: https://www.includehelp.com/kotlin/convert-temperature-from-fahrenheit-to-celsius.aspx

java转换 kotlin

Logo

开源鸿蒙跨平台开发社区汇聚开发者与厂商,共建“一次开发,多端部署”的开源生态,致力于降低跨端开发门槛,推动万物智联创新。

更多推荐