compound interest formula kotlin code example
Example: compound interest formula kotlin
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")
}