/**
 * Calculate the soil moisture based on temperature and rainfall.
 *
 * @param temperature the temperature in degrees Celsius.
 * @param rainfall the amount of rainfall in mm.
 * @return a message indicating the soil moisture condition.
 */
fun calculateSoilMoisture(temperature: Double, rainfall: Double): String {

    var soilMoisture = 0.0

    while (true) {
        when {
            temperature > 40 -> {
                soilMoisture += 10
                if (soilMoisture > 100) {
                    return "Soil moisture is excessively high."
                }
            }
            temperature > 30 -> {
                soilMoisture += 5
                when {
                    rainfall > 100 -> soilMoisture -= 10
                    rainfall <= 20 -> soilMoisture -= 5
                    else -> soilMoisture += 2
                }
            }
            temperature > 20 -> {
                if (rainfall > 60) {
                    soilMoisture += 10
                    break
                } else if (rainfall <= 10) {
                    soilMoisture -= 5
                }
            }
            else -> {
                soilMoisture -= 10
                break
            }
        }
    }

    return if (soilMoisture > 70) {
        "Soil moisture is excessively high."
    } else {
        "Soil moisture is optimal."
    }
}
/**
 * Calculate the soil moisture based on temperature and rainfall.
 *
 * @param temperature the temperature in degrees Celsius.
 * @param rainfall the amount of rainfall in mm.
 * @return a message indicating the soil moisture condition.
 */
fun calculateSoilMoisture(temperature: Double, rainfall: Double): String {
/**
 * Calculate the soil moisture based on temperature and rainfall.
 *
 * @param temperature the temperature in degrees Celsius.
 * @param rainfall the amount of rainfall in mm.
 * @return a message indicating the soil moisture condition.
 */
fun calculateSoilMoisture(temperature: Double, rainfall: Double): String {

    var soilMoisture = 0.0

    while (true) {
        when {
            temperature > 40 -> {
                soilMoisture += 10
                if (soilMoisture > 100) {
                    return "Soil moisture is excessively high."
                }
            }
            temperature > 30 -> {
                soilMoisture += 5
                when {
                    rainfall > 100 -> soilMoisture -= 10
                    rainfall <= 20 -> soilMoisture -= 5
                    else -> soilMoisture += 2
                }
            }
            temperature > 20 -> {
                if (rainfall > 60) {
                    soilMoisture += 10
                    break
                } else if (rainfall <= 10) {
                    soilMoisture -= 5
                }
            }
            else -> {
                soilMoisture -= 10
                break
            }
        }
    }

    return if (soilMoisture > 70) {
        "Soil moisture is excessively high."
    } else {
        "Soil moisture is optimal."
    }
}