/**
 * Calculate the profit for a farmer given the sales, expenses, and discount rate.
 *
 * @param sales Total sales amount.
 * @param expenses Total expenses amount.
 * @param discount Discount rate applied to the profit.
 * @return Final profit after applying the discount.
 *
 * Example:
 * calculateProfit(500.0, 300.0, 0.1) -> 155.0
 */
fun calculateProfit(sales: Double, expenses: Double, discount: Double): Double {

    val profit = sales - expenses
    val absoluteProfit = if (profit > 0) profit else -profit
    val finalProfit = absoluteProfit * (1 - discount)
    return finalProfit
}
/**
 * Calculate the profit for a farmer given the sales, expenses, and discount rate.
 *
 * @param sales Total sales amount.
 * @param expenses Total expenses amount.
 * @param discount Discount rate applied to the profit.
 * @return Final profit after applying the discount.
 *
 * Example:
 * calculateProfit(500.0, 300.0, 0.1) -> 155.0
 */
fun calculateProfit(sales: Double, expenses: Double, discount: Double): Double {
/**
 * Calculate the profit for a farmer given the sales, expenses, and discount rate.
 *
 * @param sales Total sales amount.
 * @param expenses Total expenses amount.
 * @param discount Discount rate applied to the profit.
 * @return Final profit after applying the discount.
 *
 * Example:
 * calculateProfit(500.0, 300.0, 0.1) -> 155.0
 */
fun calculateProfit(sales: Double, expenses: Double, discount: Double): Double {

    val profit = sales - expenses
    val absoluteProfit = if (profit > 0) profit else -profit
    val finalProfit = absoluteProfit * (1 - discount)
    return finalProfit
}