/**
 * This exercise requires the nurse to find the sum of common elements between two sets.
 *
 * @param set1 A set of integers
 * @param set2 Another set of integers
 * @return The sum of common elements in both sets
 *
 * The nurse needs to utilize loops to iterate over the given sets and find the common elements.
 * They should then use appropriate code to calculate the sum of these common elements and return the result.
 */
fun sumOfCommonElements(set1: Set<Int>, set2: Set<Int>): Int {

    val commonElements = mutableSetOf<Int>()

    // Iterate over set1
    for (num1 in set1) {
        // Check if the current element is present in set2
        if (num1 in set2) {
            // Add the common element to the commonElements set
            commonElements.add(num1)
        }
    }

    // Calculate the sum of common elements
    var sumOfCommon = 0

    // Iterate over the commonElements set
    for (element in commonElements) {
        // Add each common element to the sumOfCommon
        sumOfCommon += element
    }

    return sumOfCommon
}
/**
 * This exercise requires the nurse to find the sum of common elements between two sets.
 *
 * @param set1 A set of integers
 * @param set2 Another set of integers
 * @return The sum of common elements in both sets
 *
 * The nurse needs to utilize loops to iterate over the given sets and find the common elements.
 * They should then use appropriate code to calculate the sum of these common elements and return the result.
 */
fun sumOfCommonElements(set1: Set<Int>, set2: Set<Int>): Int {
/**
 * This exercise requires the nurse to find the sum of common elements between two sets.
 *
 * @param set1 A set of integers
 * @param set2 Another set of integers
 * @return The sum of common elements in both sets
 *
 * The nurse needs to utilize loops to iterate over the given sets and find the common elements.
 * They should then use appropriate code to calculate the sum of these common elements and return the result.
 */
fun sumOfCommonElements(set1: Set<Int>, set2: Set<Int>): Int {

    val commonElements = mutableSetOf<Int>()

    // Iterate over set1
    for (num1 in set1) {
        // Check if the current element is present in set2
        if (num1 in set2) {
            // Add the common element to the commonElements set
            commonElements.add(num1)
        }
    }

    // Calculate the sum of common elements
    var sumOfCommon = 0

    // Iterate over the commonElements set
    for (element in commonElements) {
        // Add each common element to the sumOfCommon
        sumOfCommon += element
    }

    return sumOfCommon
}