/**
 * Given a list of products, their corresponding prices, and the applicable discounts,
 * calculate the total cost of all products after applying the discounts.
 *
 * @param products A list of strings representing the products
 * @param prices A list of floats representing the prices of the products
 * @param discounts A list of floats representing the discount percentages
 * @return total_cost A float representing the total cost after applying the discounts
 *
 * Example:
 * calculateTotalCost(listOf("Sofa", "Chair", "Table"), listOf(500f, 250f, 400f), listOf(0.2f, 0.1f, 0.15f)) -> 840.0
 */
fun calculateTotalCost(products: List<String>, prices: List<Float>, discounts: List<Float>): Float {

    // Checking if the lengths of the arrays match
    if (products.size != prices.size || products.size != discounts.size) {
        throw IllegalArgumentException("The lengths of the arrays don't match")
    }

    // Initializing total cost variable
    var totalCost = 0f

    // Calculating the total cost after discount for each product
    for (i in products.indices) {
        totalCost += prices[i] * (1 - discounts[i])
    }

    return totalCost
}
/**
 * Given a list of products, their corresponding prices, and the applicable discounts,
 * calculate the total cost of all products after applying the discounts.
 *
 * @param products A list of strings representing the products
 * @param prices A list of floats representing the prices of the products
 * @param discounts A list of floats representing the discount percentages
 * @return total_cost A float representing the total cost after applying the discounts
 *
 * Example:
 * calculateTotalCost(listOf("Sofa", "Chair", "Table"), listOf(500f, 250f, 400f), listOf(0.2f, 0.1f, 0.15f)) -> 840.0
 */
fun calculateTotalCost(products: List<String>, prices: List<Float>, discounts: List<Float>): Float {
/**
 * Given a list of products, their corresponding prices, and the applicable discounts,
 * calculate the total cost of all products after applying the discounts.
 *
 * @param products A list of strings representing the products
 * @param prices A list of floats representing the prices of the products
 * @param discounts A list of floats representing the discount percentages
 * @return total_cost A float representing the total cost after applying the discounts
 *
 * Example:
 * calculateTotalCost(listOf("Sofa", "Chair", "Table"), listOf(500f, 250f, 400f), listOf(0.2f, 0.1f, 0.15f)) -> 840.0
 */
fun calculateTotalCost(products: List<String>, prices: List<Float>, discounts: List<Float>): Float {

    // Checking if the lengths of the arrays match
    if (products.size != prices.size || products.size != discounts.size) {
        throw IllegalArgumentException("The lengths of the arrays don't match")
    }

    // Initializing total cost variable
    var totalCost = 0f

    // Calculating the total cost after discount for each product
    for (i in products.indices) {
        totalCost += prices[i] * (1 - discounts[i])
    }

    return totalCost
}