/**
 * This function takes in two parameters:
 * - farmerExpenses: a list of the expenses incurred by the farmer
 * - farmerIncome: an integer representing the total income earned by the farmer
 *
 * It calculates the total profit made by the farmer by subtracting the sum of expenses from the income.
 * The function returns the total profit.
 *
 * Your task is to complete the code by filling in the missing parts using branching statements and integer operations.
 * Make sure to handle edge cases appropriately.
 */
fun calculateTotalProfit(farmerExpenses: List<Int>, farmerIncome: Int): Int {

    val totalExpenses = farmerExpenses.sum()

    val totalProfit = if (farmerIncome > 0) {
        farmerIncome - totalExpenses
    } else {
        0
    }

    return totalProfit
}
/**
 * This function takes in two parameters:
 * - farmerExpenses: a list of the expenses incurred by the farmer
 * - farmerIncome: an integer representing the total income earned by the farmer
 *
 * It calculates the total profit made by the farmer by subtracting the sum of expenses from the income.
 * The function returns the total profit.
 *
 * Your task is to complete the code by filling in the missing parts using branching statements and integer operations.
 * Make sure to handle edge cases appropriately.
 */
fun calculateTotalProfit(farmerExpenses: List<Int>, farmerIncome: Int): Int {
/**
 * This function takes in two parameters:
 * - farmerExpenses: a list of the expenses incurred by the farmer
 * - farmerIncome: an integer representing the total income earned by the farmer
 *
 * It calculates the total profit made by the farmer by subtracting the sum of expenses from the income.
 * The function returns the total profit.
 *
 * Your task is to complete the code by filling in the missing parts using branching statements and integer operations.
 * Make sure to handle edge cases appropriately.
 */
fun calculateTotalProfit(farmerExpenses: List<Int>, farmerIncome: Int): Int {

    val totalExpenses = farmerExpenses.sum()

    val totalProfit = if (farmerIncome > 0) {
        farmerIncome - totalExpenses
    } else {
        0
    }

    return totalProfit
}