/**
 * A farmer wants to sell a certain quantity of crops from his farm.
 * Complete the code to subtract the sold quantity from the total quantity of the given crop and return the updated quantity.
 *
 * @param farm A dictionary representing the farmer's farm with crop quantities.
 * @param crop The type of crop to sell.
 * @param quantity The quantity of crops to sell.
 * @return The updated quantity of the given crop after subtracting the sold quantity.
 */
fun sellCrops(farm: MutableMap<String, Int>, crop: String, quantity: Int): Int? {

    // Check if the crop exists in the farm dictionary
    if (crop in farm) {
        // Check if the available quantity of the crop is greater than or equal to the desired quantity to sell
        if (farm[crop]!! >= quantity) {
            // Subtract the sold quantity from the existing quantity of the crop
            farm[crop] = farm[crop]!! - quantity
            return farm[crop]
        } else {
            // If the desired quantity to sell is greater than the available quantity of the crop, display an error message
            println("Error: Insufficient quantity of $crop to sell.")
        }
    } else {
        // If the crop does not exist in the farm dictionary
        println("Error: Crop $crop does not exist in the farm.")
    }
    return null
}
/**
 * A farmer wants to sell a certain quantity of crops from his farm.
 * Complete the code to subtract the sold quantity from the total quantity of the given crop and return the updated quantity.
 *
 * @param farm A dictionary representing the farmer's farm with crop quantities.
 * @param crop The type of crop to sell.
 * @param quantity The quantity of crops to sell.
 * @return The updated quantity of the given crop after subtracting the sold quantity.
 */
fun sellCrops(farm: MutableMap<String, Int>, crop: String, quantity: Int): Int? {
/**
 * A farmer wants to sell a certain quantity of crops from his farm.
 * Complete the code to subtract the sold quantity from the total quantity of the given crop and return the updated quantity.
 *
 * @param farm A dictionary representing the farmer's farm with crop quantities.
 * @param crop The type of crop to sell.
 * @param quantity The quantity of crops to sell.
 * @return The updated quantity of the given crop after subtracting the sold quantity.
 */
fun sellCrops(farm: MutableMap<String, Int>, crop: String, quantity: Int): Int? {

    // Check if the crop exists in the farm dictionary
    if (crop in farm) {
        // Check if the available quantity of the crop is greater than or equal to the desired quantity to sell
        if (farm[crop]!! >= quantity) {
            // Subtract the sold quantity from the existing quantity of the crop
            farm[crop] = farm[crop]!! - quantity
            return farm[crop]
        } else {
            // If the desired quantity to sell is greater than the available quantity of the crop, display an error message
            println("Error: Insufficient quantity of $crop to sell.")
        }
    } else {
        // If the crop does not exist in the farm dictionary
        println("Error: Crop $crop does not exist in the farm.")
    }
    return null
}