/**
 * This function calculates the average speed of an aircraft based on the times and distances traveled.
 * The times and distances are provided as lists of equal length.
 *
 * @param times A list of time values in hours
 * @param distances A list of distance values in kilometers
 * @return The average speed in kilometers per hour
 * @throws IllegalArgumentException If the lengths of times and distances lists are not equal
 */
fun calculateAverageSpeed(times: List<Double>, distances: List<Double>): Double {

    // Check if lengths of times and distances lists are equal
    if (times.size != distances.size) {
        throw IllegalArgumentException("The lengths of times and distances lists must be equal")
    }

    // Initialize variables
    var totalDistance = 0.0
    var totalTime = 0.0

    // Iterate over the elements of the lists
    for (i in times.indices) {
        // Calculate the distance traveled
        val distanceTraveled = distances[i]

        // Calculate the time taken
        val timeTaken = times[i]

        // Update the total distance and total time
        totalDistance += distanceTraveled
        totalTime += timeTaken

        // Print the distance and time for each iteration
        println("Distance: $distanceTraveled km, Time: $timeTaken hours")
    }

    // Calculate and return the average speed
    return totalDistance / totalTime
}
/**
 * This function calculates the average speed of an aircraft based on the times and distances traveled.
 * The times and distances are provided as lists of equal length.
 *
 * @param times A list of time values in hours
 * @param distances A list of distance values in kilometers
 * @return The average speed in kilometers per hour
 * @throws IllegalArgumentException If the lengths of times and distances lists are not equal
 */
fun calculateAverageSpeed(times: List<Double>, distances: List<Double>): Double {
/**
 * This function calculates the average speed of an aircraft based on the times and distances traveled.
 * The times and distances are provided as lists of equal length.
 *
 * @param times A list of time values in hours
 * @param distances A list of distance values in kilometers
 * @return The average speed in kilometers per hour
 * @throws IllegalArgumentException If the lengths of times and distances lists are not equal
 */
fun calculateAverageSpeed(times: List<Double>, distances: List<Double>): Double {

    // Check if lengths of times and distances lists are equal
    if (times.size != distances.size) {
        throw IllegalArgumentException("The lengths of times and distances lists must be equal")
    }

    // Initialize variables
    var totalDistance = 0.0
    var totalTime = 0.0

    // Iterate over the elements of the lists
    for (i in times.indices) {
        // Calculate the distance traveled
        val distanceTraveled = distances[i]

        // Calculate the time taken
        val timeTaken = times[i]

        // Update the total distance and total time
        totalDistance += distanceTraveled
        totalTime += timeTaken

        // Print the distance and time for each iteration
        println("Distance: $distanceTraveled km, Time: $timeTaken hours")
    }

    // Calculate and return the average speed
    return totalDistance / totalTime
}