/**
 * Goal: To calculate the distance between two geographic locations using latitude and longitude values.
 * Input: Four float values representing the latitude and longitude of the two locations, in degrees.
 * Output: The distance between the two locations, in kilometers.
 */
fun calculateDistance(lat1: Double, lon1: Double, lat2: Double, lon2: Double): Double {

    val earthRadius = 6371.0  // Approximate radius of the Earth in kilometers

    // Convert degrees to radians
    val lat1Rad = Math.toRadians(lat1)
    val lon1Rad = Math.toRadians(lon1)
    val lat2Rad = Math.toRadians(lat2)
    val lon2Rad = Math.toRadians(lon2)

    // Calculate the difference between the latitude and longitude values
    val latDiff = lat2Rad - lat1Rad
    val lonDiff = lon2Rad - lon1Rad

    // Apply formula to calculate distance using spherical law of cosines
    val distance = Math.acos(Math.sin(lat1Rad) * Math.sin(lat2Rad) + Math.cos(lat1Rad) * Math.cos(lat2Rad) * Math.cos(lonDiff)) * earthRadius
    return distance
}
/**
 * Goal: To calculate the distance between two geographic locations using latitude and longitude values.
 * Input: Four float values representing the latitude and longitude of the two locations, in degrees.
 * Output: The distance between the two locations, in kilometers.
 */
fun calculateDistance(lat1: Double, lon1: Double, lat2: Double, lon2: Double): Double {
/**
 * Goal: To calculate the distance between two geographic locations using latitude and longitude values.
 * Input: Four float values representing the latitude and longitude of the two locations, in degrees.
 * Output: The distance between the two locations, in kilometers.
 */
fun calculateDistance(lat1: Double, lon1: Double, lat2: Double, lon2: Double): Double {

    val earthRadius = 6371.0  // Approximate radius of the Earth in kilometers

    // Convert degrees to radians
    val lat1Rad = Math.toRadians(lat1)
    val lon1Rad = Math.toRadians(lon1)
    val lat2Rad = Math.toRadians(lat2)
    val lon2Rad = Math.toRadians(lon2)

    // Calculate the difference between the latitude and longitude values
    val latDiff = lat2Rad - lat1Rad
    val lonDiff = lon2Rad - lon1Rad

    // Apply formula to calculate distance using spherical law of cosines
    val distance = Math.acos(Math.sin(lat1Rad) * Math.sin(lat2Rad) + Math.cos(lat1Rad) * Math.cos(lat2Rad) * Math.cos(lonDiff)) * earthRadius
    return distance
}