/**
 * The function calculates the tax amount based on the given income, deductions, and tax brackets.
 *
 * @param income the total income of the accountant
 * @param deductions a map containing the different deduction categories and their corresponding amounts
 * @param taxBrackets a map containing the different income ranges and their corresponding tax rates
 * @return the calculated tax amount
 */
fun calculateTax(income: Int, deductions: Map<String, Int>, taxBrackets: Map<IntRange, Double>): Double {

    val taxableIncome = income - deductions.values.sum()
    var taxAmount = 0.0

    for (bracket in taxBrackets) {
        if (taxableIncome > bracket.key.first) {
            if (taxableIncome <= bracket.key.last) {
                taxAmount += (taxableIncome - bracket.key.first) * bracket.value
            } else {
                taxAmount += (bracket.key.last - bracket.key.first) * bracket.value
            }
        }
    }

    return taxAmount
}
/**
 * The function calculates the tax amount based on the given income, deductions, and tax brackets.
 *
 * @param income the total income of the accountant
 * @param deductions a map containing the different deduction categories and their corresponding amounts
 * @param taxBrackets a map containing the different income ranges and their corresponding tax rates
 * @return the calculated tax amount
 */
fun calculateTax(income: Int, deductions: Map<String, Int>, taxBrackets: Map<IntRange, Double>): Double {
/**
 * The function calculates the tax amount based on the given income, deductions, and tax brackets.
 *
 * @param income the total income of the accountant
 * @param deductions a map containing the different deduction categories and their corresponding amounts
 * @param taxBrackets a map containing the different income ranges and their corresponding tax rates
 * @return the calculated tax amount
 */
fun calculateTax(income: Int, deductions: Map<String, Int>, taxBrackets: Map<IntRange, Double>): Double {

    val taxableIncome = income - deductions.values.sum()
    var taxAmount = 0.0

    for (bracket in taxBrackets) {
        if (taxableIncome > bracket.key.first) {
            if (taxableIncome <= bracket.key.last) {
                taxAmount += (taxableIncome - bracket.key.first) * bracket.value
            } else {
                taxAmount += (bracket.key.last - bracket.key.first) * bracket.value
            }
        }
    }

    return taxAmount
}