📜  复利公式 kotlin - 任何代码示例

📅  最后修改于: 2022-03-11 15:00:09.851000             🧑  作者: Mango

代码示例1
import java.util.*

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

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

    //Input Amount
    print("Enter Principal Amount : ")
    val principalAmount = scanner.nextDouble()

    //Input Interest Rate
    print("Enter Rate of Interest : ")
    val rateOfInterest = scanner.nextDouble()

    //Input time in years
    print("Enter Time : ")
    val time = scanner.nextDouble()

    //Calculate Compound Interest
    val compoundInterest = principalAmount.toDouble() * Math.pow((1 + rateOfInterest.toDouble()/100.00),time.toDouble())

    //Print Compound Interest
    println("Compound Interest is :$compoundInterest")
}