/**
 * This function computes the average speed of an aircraft given the distance travelled and the time taken.
 * The function uses both for loop and while loop constructs to calculate the average speed.
 *
 * @param distance The distance travelled by the aircraft in kilometers.
 * @param time The time taken by the aircraft to cover the distance in hours.
 * @return The average speed of the aircraft in kilometers per hour.
 */
fun computeAverageSpeed(distance: Double, time: Double): Pair<Double, Double> {

    // Using a for loop
    var speedSum = 0.0
    for (i in 1..time.toInt()) {
        speedSum += distance / i
    }
    val averageSpeedForLoop = speedSum / time

    // Using a while loop
    speedSum = 0.0
    var count = 1
    while (count <= time.toInt()) {
        speedSum += distance / count
        count++
    }
    val averageSpeedWhileLoop = speedSum / time

    return Pair(averageSpeedForLoop, averageSpeedWhileLoop)
}
/**
 * This function computes the average speed of an aircraft given the distance travelled and the time taken.
 * The function uses both for loop and while loop constructs to calculate the average speed.
 *
 * @param distance The distance travelled by the aircraft in kilometers.
 * @param time The time taken by the aircraft to cover the distance in hours.
 * @return The average speed of the aircraft in kilometers per hour.
 */
fun computeAverageSpeed(distance: Double, time: Double): Pair<Double, Double> {
/**
 * This function computes the average speed of an aircraft given the distance travelled and the time taken.
 * The function uses both for loop and while loop constructs to calculate the average speed.
 *
 * @param distance The distance travelled by the aircraft in kilometers.
 * @param time The time taken by the aircraft to cover the distance in hours.
 * @return The average speed of the aircraft in kilometers per hour.
 */
fun computeAverageSpeed(distance: Double, time: Double): Pair<Double, Double> {

    // Using a for loop
    var speedSum = 0.0
    for (i in 1..time.toInt()) {
        speedSum += distance / i
    }
    val averageSpeedForLoop = speedSum / time

    // Using a while loop
    speedSum = 0.0
    var count = 1
    while (count <= time.toInt()) {
        speedSum += distance / count
        count++
    }
    val averageSpeedWhileLoop = speedSum / time

    return Pair(averageSpeedForLoop, averageSpeedWhileLoop)
}