/**
 * This function calculates the remaining fuel in a spacecraft
 * after a certain period of time based on the spacecraft's initial
 * fuel quantity and velocity. It also handles any potential errors.
 *
 * @param fuel The initial fuel quantity in liters.
 * @param velocity The spacecraft's velocity in km/h.
 * @return The remaining fuel quantity after a certain time period.
 * @throws IllegalArgumentException If the fuel quantity or velocity is negative.
 * @throws ArithmeticException If the velocity is zero.
 *
 * Example:
 * val remainingFuel = calculateRemainingFuel(500.0, 200.0)
 * println(remainingFuel)  // Output: 375.0
 */
fun calculateRemainingFuel(fuel: Double, velocity: Double): Double {

    if (fuel < 0 || velocity < 0) {
        throw IllegalArgumentException("Fuel quantity and velocity cannot be negative.")
    }

    if (velocity == 0.0) {
        throw ArithmeticException("Velocity cannot be zero.")
    }

    return try {
        fuel / velocity
    } catch (e: ArithmeticException) {
        println("An unexpected error occurred. Please check your inputs.")
        0.0
    } catch (e: Exception) {
        println("An error occurred: ${e.message}")
        0.0
    }
}
/**
 * This function calculates the remaining fuel in a spacecraft
 * after a certain period of time based on the spacecraft's initial
 * fuel quantity and velocity. It also handles any potential errors.
 *
 * @param fuel The initial fuel quantity in liters.
 * @param velocity The spacecraft's velocity in km/h.
 * @return The remaining fuel quantity after a certain time period.
 * @throws IllegalArgumentException If the fuel quantity or velocity is negative.
 * @throws ArithmeticException If the velocity is zero.
 *
 * Example:
 * val remainingFuel = calculateRemainingFuel(500.0, 200.0)
 * println(remainingFuel)  // Output: 375.0
 */
fun calculateRemainingFuel(fuel: Double, velocity: Double): Double {
/**
 * This function calculates the remaining fuel in a spacecraft
 * after a certain period of time based on the spacecraft's initial
 * fuel quantity and velocity. It also handles any potential errors.
 *
 * @param fuel The initial fuel quantity in liters.
 * @param velocity The spacecraft's velocity in km/h.
 * @return The remaining fuel quantity after a certain time period.
 * @throws IllegalArgumentException If the fuel quantity or velocity is negative.
 * @throws ArithmeticException If the velocity is zero.
 *
 * Example:
 * val remainingFuel = calculateRemainingFuel(500.0, 200.0)
 * println(remainingFuel)  // Output: 375.0
 */
fun calculateRemainingFuel(fuel: Double, velocity: Double): Double {

    if (fuel < 0 || velocity < 0) {
        throw IllegalArgumentException("Fuel quantity and velocity cannot be negative.")
    }

    if (velocity == 0.0) {
        throw ArithmeticException("Velocity cannot be zero.")
    }

    return try {
        fuel / velocity
    } catch (e: ArithmeticException) {
        println("An unexpected error occurred. Please check your inputs.")
        0.0
    } catch (e: Exception) {
        println("An error occurred: ${e.message}")
        0.0
    }
}