/**
 * Calculates the interest earned on a given principal amount based on a given interest rate.
 *
 * @param rate The interest rate.
 * @param principal The principal amount.
 * @return The interest amount.
 */
fun calculateInterest(rate: Double, principal: Double): Double {

    // Calculate the interest amount
    val interest = principal * rate
    
    // Print the interest amount in formatted output
    println("The interest earned on a principal amount of $$principal at an interest rate of ${"%.2f".format(rate)}% is $${"%.2f".format(interest)}")
    
    // Return the interest amount
    return interest
}
/**
 * Calculates the interest earned on a given principal amount based on a given interest rate.
 *
 * @param rate The interest rate.
 * @param principal The principal amount.
 * @return The interest amount.
 */
fun calculateInterest(rate: Double, principal: Double): Double {
/**
 * Calculates the interest earned on a given principal amount based on a given interest rate.
 *
 * @param rate The interest rate.
 * @param principal The principal amount.
 * @return The interest amount.
 */
fun calculateInterest(rate: Double, principal: Double): Double {

    // Calculate the interest amount
    val interest = principal * rate
    
    // Print the interest amount in formatted output
    println("The interest earned on a principal amount of $$principal at an interest rate of ${"%.2f".format(rate)}% is $${"%.2f".format(interest)}")
    
    // Return the interest amount
    return interest
}