/**
 * Calculate the total bill for an electrician based on the given electricity consumption.
 *
 * @param electricityConsumption A map with the number of units consumed for different appliances.
 * @return The total bill for the electrician.
 *
 * Exercise:
 * Complete the function to calculate the total bill for an electrician using the given electricity consumption.
 * The electricity tariff for the first 100 units is $0.10 per unit,
 * for the next 50 units is $0.15 per unit,
 * for the next 100 units is $0.20 per unit, and
 * for any units above 250 is $0.25 per unit.
 * The function should return the total bill rounded to two decimal places.
 *
 * Hint:
 * - Use the nested ternary operators to determine the tariff based on the electricity consumption.
 * - Iterate over the map entries to calculate the total units consumed.
 */
fun calculateTotalBill(electricityConsumption: Map<String, Int>): Double {

    var totalUnits = 0
    for ((_, units) in electricityConsumption) {
        totalUnits += units
    }

    return String.format("%.2f", totalUnits * when {
        totalUnits <= 100 -> 0.10
        totalUnits <= 150 -> 0.15
        totalUnits <= 250 -> 0.20
        else -> 0.25
    }).toDouble()
}
/**
 * Calculate the total bill for an electrician based on the given electricity consumption.
 *
 * @param electricityConsumption A map with the number of units consumed for different appliances.
 * @return The total bill for the electrician.
 *
 * Exercise:
 * Complete the function to calculate the total bill for an electrician using the given electricity consumption.
 * The electricity tariff for the first 100 units is $0.10 per unit,
 * for the next 50 units is $0.15 per unit,
 * for the next 100 units is $0.20 per unit, and
 * for any units above 250 is $0.25 per unit.
 * The function should return the total bill rounded to two decimal places.
 *
 * Hint:
 * - Use the nested ternary operators to determine the tariff based on the electricity consumption.
 * - Iterate over the map entries to calculate the total units consumed.
 */
fun calculateTotalBill(electricityConsumption: Map<String, Int>): Double {
/**
 * Calculate the total bill for an electrician based on the given electricity consumption.
 *
 * @param electricityConsumption A map with the number of units consumed for different appliances.
 * @return The total bill for the electrician.
 *
 * Exercise:
 * Complete the function to calculate the total bill for an electrician using the given electricity consumption.
 * The electricity tariff for the first 100 units is $0.10 per unit,
 * for the next 50 units is $0.15 per unit,
 * for the next 100 units is $0.20 per unit, and
 * for any units above 250 is $0.25 per unit.
 * The function should return the total bill rounded to two decimal places.
 *
 * Hint:
 * - Use the nested ternary operators to determine the tariff based on the electricity consumption.
 * - Iterate over the map entries to calculate the total units consumed.
 */
fun calculateTotalBill(electricityConsumption: Map<String, Int>): Double {

    var totalUnits = 0
    for ((_, units) in electricityConsumption) {
        totalUnits += units
    }

    return String.format("%.2f", totalUnits * when {
        totalUnits <= 100 -> 0.10
        totalUnits <= 150 -> 0.15
        totalUnits <= 250 -> 0.20
        else -> 0.25
    }).toDouble()
}