/**
 * Given a distance in kilometers and the number of decimal places to round to,
 * return a formatted string representation of the distance with the specified precision.
 *
 * Example:
 * formatDistance(1000.5678, 2) -> '1000.57 km'
 *
 * @param distance The distance in kilometers.
 * @param decPlaces The number of decimal places to round to.
 * @return The formatted string representation of the distance with the specified precision.
 *
 * Note:
 * - The final result should always be rounded up if the last decimal place is greater than or equal to 5.
 */
fun formatDistance(distance: Double, decPlaces: Int): String {

    val roundedDistance = String.format("%.${decPlaces}f km", distance)  // Round to the specified decimal places
    return roundedDistance
}
/**
 * Given a distance in kilometers and the number of decimal places to round to,
 * return a formatted string representation of the distance with the specified precision.
 *
 * Example:
 * formatDistance(1000.5678, 2) -> '1000.57 km'
 *
 * @param distance The distance in kilometers.
 * @param decPlaces The number of decimal places to round to.
 * @return The formatted string representation of the distance with the specified precision.
 *
 * Note:
 * - The final result should always be rounded up if the last decimal place is greater than or equal to 5.
 */
fun formatDistance(distance: Double, decPlaces: Int): String {
/**
 * Given a distance in kilometers and the number of decimal places to round to,
 * return a formatted string representation of the distance with the specified precision.
 *
 * Example:
 * formatDistance(1000.5678, 2) -> '1000.57 km'
 *
 * @param distance The distance in kilometers.
 * @param decPlaces The number of decimal places to round to.
 * @return The formatted string representation of the distance with the specified precision.
 *
 * Note:
 * - The final result should always be rounded up if the last decimal place is greater than or equal to 5.
 */
fun formatDistance(distance: Double, decPlaces: Int): String {

    val roundedDistance = String.format("%.${decPlaces}f km", distance)  // Round to the specified decimal places
    return roundedDistance
}