kotlin 计算平方
Compound interest is the sum of principal amount and interest of interest.
复利是本金和利息之和。
Given, principal, rate, and time, we have to calculate the Compound interest.
给定本金,利率和时间,我们必须计算复利。
Formula to calculate Compound interest is: P * (Math.pow(( 1 + R/100), T)
计算复利的公式为:P *(Math.pow((1 + R / 100),T)
Where,
哪里,
P is Principal amount.
P是本金。
R is rate of interest per annum.
R是每年的利率。
T is time in years.
T是以年为单位的时间。
Example:
例:
Input:
P = 5000
R = 12
T = 5
Output:
Compound Interest = 8811.708416000003
计算Kotlin复利的程序 (Program to calculate Compound interest 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 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")
}
Output
输出量
Enter Principal Amount : 5000
Enter Rate of Interest : 12
Enter Time : 5
Compound Interest is :8811.708416000003
翻译自: https://www.includehelp.com/kotlin/calculate-compound-interest.aspx
kotlin 计算平方