/**
 * Calculate the total amount of penalties for a lawyer based on their monthly income and the number of months.
 *
 * @param monthlyIncome The lawyer's monthly income.
 * @param months The number of months to calculate the penalties for.
 * @return The total amount of penalties incurred.
 * @throws IllegalArgumentException If any of the arguments are negative integers.
 *
 * Examples:
 * calculatePenalties(5000, 6) -> 120
 * calculatePenalties(10000, 9) -> 270
 * calculatePenalties(2500, 12) -> 360
 */
fun calculatePenalties(monthlyIncome: Int, months: Int): Int {

    if (monthlyIncome < 0 || months < 0) {
        throw IllegalArgumentException("The monthly income and number of months must be positive integers.")
    }

    val penaltyRate = 0.02  // 2% penalty rate for every month
    var totalPenalties = 0

    var remainingIncome = monthlyIncome

    repeat(months) {
        val penalty = (remainingIncome * penaltyRate).toInt()
        totalPenalties += penalty
        remainingIncome -= penalty
    }

    return totalPenalties
}
/**
 * Calculate the total amount of penalties for a lawyer based on their monthly income and the number of months.
 *
 * @param monthlyIncome The lawyer's monthly income.
 * @param months The number of months to calculate the penalties for.
 * @return The total amount of penalties incurred.
 * @throws IllegalArgumentException If any of the arguments are negative integers.
 *
 * Examples:
 * calculatePenalties(5000, 6) -> 120
 * calculatePenalties(10000, 9) -> 270
 * calculatePenalties(2500, 12) -> 360
 */
fun calculatePenalties(monthlyIncome: Int, months: Int): Int {
/**
 * Calculate the total amount of penalties for a lawyer based on their monthly income and the number of months.
 *
 * @param monthlyIncome The lawyer's monthly income.
 * @param months The number of months to calculate the penalties for.
 * @return The total amount of penalties incurred.
 * @throws IllegalArgumentException If any of the arguments are negative integers.
 *
 * Examples:
 * calculatePenalties(5000, 6) -> 120
 * calculatePenalties(10000, 9) -> 270
 * calculatePenalties(2500, 12) -> 360
 */
fun calculatePenalties(monthlyIncome: Int, months: Int): Int {

    if (monthlyIncome < 0 || months < 0) {
        throw IllegalArgumentException("The monthly income and number of months must be positive integers.")
    }

    val penaltyRate = 0.02  // 2% penalty rate for every month
    var totalPenalties = 0

    var remainingIncome = monthlyIncome

    repeat(months) {
        val penalty = (remainingIncome * penaltyRate).toInt()
        totalPenalties += penalty
        remainingIncome -= penalty
    }

    return totalPenalties
}