/**
 * Calculates the total payment for a nurse based on the hours worked, hourly rate, bonus, and number of patients visited.
 *
 * @param hoursWorked The number of hours worked by the nurse.
 * @param hourlyRate The hourly rate of the nurse.
 * @param bonus The bonus amount received by the nurse.
 * @param patientsVisited A list of integers representing the number of patients visited each day.
 * @return The total payment for the nurse.
 */
fun calculateNursePayment(hoursWorked: Int, hourlyRate: Double, bonus: Double, patientsVisited: List<Int>): Double {

    var totalPayment = 0.0

    if (hoursWorked > 40) {
        totalPayment += hourlyRate * 40
        val overtimePayment = (hoursWorked - 40) * (hourlyRate * 1.5)
        totalPayment += overtimePayment
    } else {
        totalPayment += hourlyRate * hoursWorked
    }

    for (patients in patientsVisited) {
        totalPayment += patients * bonus
    }

    return totalPayment
}

// Example usage:
val hours = 50
val rate = 20.0
val bonus = 5.0
val patients = listOf(3, 4, 2)
/**
 * Calculates the total payment for a nurse based on the hours worked, hourly rate, bonus, and number of patients visited.
 *
 * @param hoursWorked The number of hours worked by the nurse.
 * @param hourlyRate The hourly rate of the nurse.
 * @param bonus The bonus amount received by the nurse.
 * @param patientsVisited A list of integers representing the number of patients visited each day.
 * @return The total payment for the nurse.
 */
fun calculateNursePayment(hoursWorked: Int, hourlyRate: Double, bonus: Double, patientsVisited: List<Int>): Double {
/**
 * Calculates the total payment for a nurse based on the hours worked, hourly rate, bonus, and number of patients visited.
 *
 * @param hoursWorked The number of hours worked by the nurse.
 * @param hourlyRate The hourly rate of the nurse.
 * @param bonus The bonus amount received by the nurse.
 * @param patientsVisited A list of integers representing the number of patients visited each day.
 * @return The total payment for the nurse.
 */
fun calculateNursePayment(hoursWorked: Int, hourlyRate: Double, bonus: Double, patientsVisited: List<Int>): Double {

    var totalPayment = 0.0

    if (hoursWorked > 40) {
        totalPayment += hourlyRate * 40
        val overtimePayment = (hoursWorked - 40) * (hourlyRate * 1.5)
        totalPayment += overtimePayment
    } else {
        totalPayment += hourlyRate * hoursWorked
    }

    for (patients in patientsVisited) {
        totalPayment += patients * bonus
    }

    return totalPayment
}

// Example usage:
val hours = 50
val rate = 20.0
val bonus = 5.0
val patients = listOf(3, 4, 2)