kotlin 程序入口_Kotlin程序找到圆的区域

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 程序入口

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值