kotlin 查找id

Formula to find volume of Sphere: volume =(4/3)*PI*r^3

查找球体体积的公式: volume =(4/3)* PI * r ^ 3

Given the value of radius, we have to find the volume of Sphere.

给定半径的值,我们必须找到球体的体积。

Example:

例:

    Input:
    radius = 7

    Output:
    volume = 1436.7550402417319

程序在Kotlin中查找Sphere的体积 (Program to find volume of Sphere in Kotlin)

package com.includehelp

import java.util.*
import kotlin.math.pow

//Main Function , Entry point of Program
fun main(args: Array<String>) {

    //Input Stream
    val scanner = Scanner(System.`in`)

    //Input Radius
    print("Enter Radius of Sphere : ")
    val radius = scanner.nextDouble()

    //Sphere Volume
    val sphereVolume = (4.0/3.0)*Math.PI*radius.pow(3)

    //Print Volume
    println("Sphere Volume on radius $radius is : $sphereVolume")
}

Output

输出量

Run 1:
Enter Radius of Sphere : 7
Sphere Volume on radius 7.0 is : 1436.7550402417319
---
Run 2:
Enter Radius of Sphere : 21
Sphere Volume on radius 21.0 is : 38792.38608652676


翻译自: https://www.includehelp.com/kotlin/find-volume-of-sphere.aspx

kotlin 查找id

Logo

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

更多推荐