/**
 * Given the initial population, birth rate and death rate, this function calculates the population growth.
 *
 * @param initialPopulation The initial population size.
 * @param birthRate The rate at which the population increases per year (value between 0 and 1).
 * @param deathRate The rate at which the population decreases per year (value between 0 and 1).
 * @return The population size after a certain number of years.
 */
fun calculatePopulationGrowth(initialPopulation: Int, birthRate: Double, deathRate: Double): Int {

    var years = 0
    var population = initialPopulation

    while (true) {  // Infinite while loop until user manually stops the program
        population += (population * birthRate).toInt() - (population * deathRate).toInt()
        years++

        if (population <= 0) {
            println("The population has gone extinct after $years years.")
            break
        }
    }

    return population
}
/**
 * Given the initial population, birth rate and death rate, this function calculates the population growth.
 *
 * @param initialPopulation The initial population size.
 * @param birthRate The rate at which the population increases per year (value between 0 and 1).
 * @param deathRate The rate at which the population decreases per year (value between 0 and 1).
 * @return The population size after a certain number of years.
 */
fun calculatePopulationGrowth(initialPopulation: Int, birthRate: Double, deathRate: Double): Int {
/**
 * Given the initial population, birth rate and death rate, this function calculates the population growth.
 *
 * @param initialPopulation The initial population size.
 * @param birthRate The rate at which the population increases per year (value between 0 and 1).
 * @param deathRate The rate at which the population decreases per year (value between 0 and 1).
 * @return The population size after a certain number of years.
 */
fun calculatePopulationGrowth(initialPopulation: Int, birthRate: Double, deathRate: Double): Int {

    var years = 0
    var population = initialPopulation

    while (true) {  // Infinite while loop until user manually stops the program
        population += (population * birthRate).toInt() - (population * deathRate).toInt()
        years++

        if (population <= 0) {
            println("The population has gone extinct after $years years.")
            break
        }
    }

    return population
}