/**
 * Calculate the interest earned on a bank account based on the balance and interest rate.
 *
 * @param interestRate The interest rate as a decimal value.
 * @param balance The current account balance.
 * @return The calculated interest earned.
 */
fun calculateInterest(interestRate: Double, balance: Double): Double {

    // Determine the absolute value of the balance
    val absBalance = Math.abs(balance)

    // Calculate the interest using a ternary operator with multiple conditions
    val interest = if (absBalance > 1000) {
        interestRate * absBalance
    } else if (absBalance >= 500) {
        interestRate * absBalance / 2
    } else {
        0.0
    }

    return interest
}
/**
 * Calculate the interest earned on a bank account based on the balance and interest rate.
 *
 * @param interestRate The interest rate as a decimal value.
 * @param balance The current account balance.
 * @return The calculated interest earned.
 */
fun calculateInterest(interestRate: Double, balance: Double): Double {
/**
 * Calculate the interest earned on a bank account based on the balance and interest rate.
 *
 * @param interestRate The interest rate as a decimal value.
 * @param balance The current account balance.
 * @return The calculated interest earned.
 */
fun calculateInterest(interestRate: Double, balance: Double): Double {

    // Determine the absolute value of the balance
    val absBalance = Math.abs(balance)

    // Calculate the interest using a ternary operator with multiple conditions
    val interest = if (absBalance > 1000) {
        interestRate * absBalance
    } else if (absBalance >= 500) {
        interestRate * absBalance / 2
    } else {
        0.0
    }

    return interest
}