/**
 * A Farmer wants to calculate the total harvest by multiplying the quantity of each fruit he has collected.
 * Complete the function below to calculate the total harvest by multiplying the quantity of each fruit.
 *
 * @param fruits A string representing the names of fruits separated by commas.
 * @param quantity A string representing the quantity of each corresponding fruit separated by commas.
 * @return Total harvest of the farmer.
 *
 * Example:
 * calculateTotalHarvest("apple,orange,banana", "10,15,5") -> 750
 * calculateTotalHarvest("pineapple", "20") -> 20
 * calculateTotalHarvest("", "") -> 0
 */
fun calculateTotalHarvest(fruits: String, quantity: String): Int {

    var totalHarvest = 0
    val fruitsList = fruits.split(",")
    val quantityList = quantity.split(",")

    var index = 0

    while (index < fruitsList.size) {
        totalHarvest += quantityList[index].toInt() * fruitsList[index].length
        index++
    }

    return totalHarvest
}
/**
 * A Farmer wants to calculate the total harvest by multiplying the quantity of each fruit he has collected.
 * Complete the function below to calculate the total harvest by multiplying the quantity of each fruit.
 *
 * @param fruits A string representing the names of fruits separated by commas.
 * @param quantity A string representing the quantity of each corresponding fruit separated by commas.
 * @return Total harvest of the farmer.
 *
 * Example:
 * calculateTotalHarvest("apple,orange,banana", "10,15,5") -> 750
 * calculateTotalHarvest("pineapple", "20") -> 20
 * calculateTotalHarvest("", "") -> 0
 */
fun calculateTotalHarvest(fruits: String, quantity: String): Int {
/**
 * A Farmer wants to calculate the total harvest by multiplying the quantity of each fruit he has collected.
 * Complete the function below to calculate the total harvest by multiplying the quantity of each fruit.
 *
 * @param fruits A string representing the names of fruits separated by commas.
 * @param quantity A string representing the quantity of each corresponding fruit separated by commas.
 * @return Total harvest of the farmer.
 *
 * Example:
 * calculateTotalHarvest("apple,orange,banana", "10,15,5") -> 750
 * calculateTotalHarvest("pineapple", "20") -> 20
 * calculateTotalHarvest("", "") -> 0
 */
fun calculateTotalHarvest(fruits: String, quantity: String): Int {

    var totalHarvest = 0
    val fruitsList = fruits.split(",")
    val quantityList = quantity.split(",")

    var index = 0

    while (index < fruitsList.size) {
        totalHarvest += quantityList[index].toInt() * fruitsList[index].length
        index++
    }

    return totalHarvest
}