/**
 * This function calculates the compound interest for a given principal amount,
 * interest rate and number of years.
 *
 * @param principal the initial amount of money
 * @param rate the annual interest rate (in decimal form)
 * @param years the number of years
 * @return the total amount of money after compound interest
 */
fun calculateInterest(principal: Double, rate: Double, years: Int): Double {

    var interest = principal
    var time = 1
    while (time <= years) {
        interest += interest * rate  // compound interest formula
        time++
    }
    return interest
}
/**
 * This function calculates the compound interest for a given principal amount,
 * interest rate and number of years.
 *
 * @param principal the initial amount of money
 * @param rate the annual interest rate (in decimal form)
 * @param years the number of years
 * @return the total amount of money after compound interest
 */
fun calculateInterest(principal: Double, rate: Double, years: Int): Double {
/**
 * This function calculates the compound interest for a given principal amount,
 * interest rate and number of years.
 *
 * @param principal the initial amount of money
 * @param rate the annual interest rate (in decimal form)
 * @param years the number of years
 * @return the total amount of money after compound interest
 */
fun calculateInterest(principal: Double, rate: Double, years: Int): Double {

    var interest = principal
    var time = 1
    while (time <= years) {
        interest += interest * rate  // compound interest formula
        time++
    }
    return interest
}