/**
 * Calculate the total profit made by a farmer from selling different fruits.
 *
 * @param fruitsDict A dictionary where the keys are the names of the fruits and the values are the prices per kg.
 * @param soldFruits A set containing the names of the fruits sold by the farmer.
 * @return The total profit made by the farmer.
 *
 * Example:
 * val fruitsDict = mapOf("apple" to 2.5, "banana" to 1.8, "mango" to 3.2, "kiwi" to 2.7)
 * val soldFruits = setOf("apple", "banana", "kiwi")
 * calculateProfit(fruitsDict, soldFruits) => 7.0
 */
fun calculateProfit(fruitsDict: Map<String, Double>, soldFruits: Set<String>): Double {

    var totalProfit = 0.0

    for (fruit in soldFruits) {
        if (fruit in fruitsDict) {
            totalProfit += fruitsDict[fruit] ?: 0.0
        }
    }

    return totalProfit
}
/**
 * Calculate the total profit made by a farmer from selling different fruits.
 *
 * @param fruitsDict A dictionary where the keys are the names of the fruits and the values are the prices per kg.
 * @param soldFruits A set containing the names of the fruits sold by the farmer.
 * @return The total profit made by the farmer.
 *
 * Example:
 * val fruitsDict = mapOf("apple" to 2.5, "banana" to 1.8, "mango" to 3.2, "kiwi" to 2.7)
 * val soldFruits = setOf("apple", "banana", "kiwi")
 * calculateProfit(fruitsDict, soldFruits) => 7.0
 */
fun calculateProfit(fruitsDict: Map<String, Double>, soldFruits: Set<String>): Double {
/**
 * Calculate the total profit made by a farmer from selling different fruits.
 *
 * @param fruitsDict A dictionary where the keys are the names of the fruits and the values are the prices per kg.
 * @param soldFruits A set containing the names of the fruits sold by the farmer.
 * @return The total profit made by the farmer.
 *
 * Example:
 * val fruitsDict = mapOf("apple" to 2.5, "banana" to 1.8, "mango" to 3.2, "kiwi" to 2.7)
 * val soldFruits = setOf("apple", "banana", "kiwi")
 * calculateProfit(fruitsDict, soldFruits) => 7.0
 */
fun calculateProfit(fruitsDict: Map<String, Double>, soldFruits: Set<String>): Double {

    var totalProfit = 0.0

    for (fruit in soldFruits) {
        if (fruit in fruitsDict) {
            totalProfit += fruitsDict[fruit] ?: 0.0
        }
    }

    return totalProfit
}