# Program to calculate compound interest in Kotlin

In this article, We will learn program to calculate compound interest in Kotlin. In simple terms, Compound interest is the sum of principal amount and interest of interest. Compound Interest Formula

Source Code:
fun main(args: Array<String>)
{
try
{
print("Enter principle amount : ")
print("Enter interest rate : ")
print("Enter number of years : ")

val ci = principle.toDouble() * Math.pow((1 + rate.toDouble()/100.00),time.toDouble())
println("Compound Interest is : \$ci")
}
catch (exception : NumberFormatException)
{
print(exception)
}
}
Output:
Enter principle amount : 2000
Enter interest rate : 2
Enter number of years : 3
Compound Interest is : 2122.416 Calculate Compound Interest in Kotlin - Output
Description:
In this program, we will take input from the user to enter to get principal amount, rate and years value. To do so we have used readLine() function.

compound interest formula is A = P(1 + r/n)^nt. Where "P" is the principal amount, "r" is an annual nominal interest rate and "n" is the number of years. Same is printed using print() function.