/**
 * The function calculates the average brightness of stars given their magnitudes.
 *
 * @param stars A dictionary where the keys are star names and the values are magnitudes.
 * @return The average brightness of the stars.
 *
 * Example:
 * stars = mapOf("Star1" to 0.5, "Star2" to 1.2, "Star3" to 2.7, "Star4" to 0.8, "Star5" to 1.5)
 * calculateAverageBrightness(stars) // Output: 1.34
 */
fun calculateAverageBrightness(stars: Map<String, Double>): Double {

    var totalBrightness = 0.0
    var count = 0

    for ((_, magnitude) in stars) {
        // Calculate the brightness using magnitude and add it to the totalBrightness variable
        totalBrightness += magnitude
        count++
    }

    // Calculate and return the average brightness
    return if (count > 0) totalBrightness / count else 0.0
}
/**
 * The function calculates the average brightness of stars given their magnitudes.
 *
 * @param stars A dictionary where the keys are star names and the values are magnitudes.
 * @return The average brightness of the stars.
 *
 * Example:
 * stars = mapOf("Star1" to 0.5, "Star2" to 1.2, "Star3" to 2.7, "Star4" to 0.8, "Star5" to 1.5)
 * calculateAverageBrightness(stars) // Output: 1.34
 */
fun calculateAverageBrightness(stars: Map<String, Double>): Double {
/**
 * The function calculates the average brightness of stars given their magnitudes.
 *
 * @param stars A dictionary where the keys are star names and the values are magnitudes.
 * @return The average brightness of the stars.
 *
 * Example:
 * stars = mapOf("Star1" to 0.5, "Star2" to 1.2, "Star3" to 2.7, "Star4" to 0.8, "Star5" to 1.5)
 * calculateAverageBrightness(stars) // Output: 1.34
 */
fun calculateAverageBrightness(stars: Map<String, Double>): Double {

    var totalBrightness = 0.0
    var count = 0

    for ((_, magnitude) in stars) {
        // Calculate the brightness using magnitude and add it to the totalBrightness variable
        totalBrightness += magnitude
        count++
    }

    // Calculate and return the average brightness
    return if (count > 0) totalBrightness / count else 0.0
}