kotlin 程序入口
Given radius of the circle, we have to find the area of circle.
给定圆的半径,我们必须找到圆的面积。
Example:
例:
Input:
Radius: 3
Output:
Area of circle: 28.259999999999998
To find the area of the circle, we use the formula: π r2.
为了找到圆的面积 ,我们使用公式: πr 2 。
Here,
这里,
π stands for PI which is a mathematical constant and it's value of 3.14, it defined as the ratio of a circle’s circumference to its diameter and it also has the various equivalent definitions.
π代表PI ,它是一个数学常数,其值为3.14,它定义为圆的周长与其直径之比,并且还具有各种等效定义。
r is the radius of the circle.
r是圆的半径。
程序在Kotlin查找圆的区域 (Program to find area of circle in Kotlin)
package com.includehelp.basic
import java.util.*
// PI Constant Value
val PI = 3.14
/* function to calculate area of circle of given radius */
fun getAreaOfCirlce(radius: Double): Double {
return PI * radius * radius
}
// Main Method Entry Point of Program
fun main(args:Array<String>){
val sc = Scanner(System.`in`)
// Input Radius
println("Enter Circle Radius : ")
val radius = sc.nextDouble()
// Call function to get Area of Circle
val areaOfCircle = getAreaOfCirlce(radius)
// Print Area of Circle
println("Area of Circle : $areaOfCircle")
}
Output
输出量
Run 1:
Enter Circle Radius :
3
Area of Circle : 28.259999999999998
-----
Run 2:
Enter Circle Radius :
8
Area of Circle : 200.96
翻译自: https://www.includehelp.com/kotlin/find-area-of-circle.aspx
kotlin 程序入口