/**
 * A biologist wants to calculate the growth rate of a population of organisms.
 * The biologist knows the initial population, the final population, and the time span in years.
 *
 * Your task is to complete the code below that calculates the growth rate using the given inputs.
 *
 * The growth rate is calculated as the multiplication of the following two formulas:
 * 1. The change in population size: final population minus initial population
 * 2. The reciprocal of the time span: 1 divided by the time span in years
 *
 * The result should be rounded to 4 decimal places.
 *
 * For example, if the initial population is 100, final population is 200, and time span is 5 years,
 * the growth rate would be (200 - 100) * (1 / 5) = 100 * 0.2 = 20.0000.
 *
 * Complete the code to solve the exercise.
 */
fun calculateGrowthRate(initialPopulation: Int, finalPopulation: Int, timeInYears: Int): Double {

    val growthRate = ((finalPopulation - initialPopulation) * (1.0 / timeInYears)).toDouble()
    return String.format("%.4f", growthRate).toDouble()
}
/**
 * A biologist wants to calculate the growth rate of a population of organisms.
 * The biologist knows the initial population, the final population, and the time span in years.
 *
 * Your task is to complete the code below that calculates the growth rate using the given inputs.
 *
 * The growth rate is calculated as the multiplication of the following two formulas:
 * 1. The change in population size: final population minus initial population
 * 2. The reciprocal of the time span: 1 divided by the time span in years
 *
 * The result should be rounded to 4 decimal places.
 *
 * For example, if the initial population is 100, final population is 200, and time span is 5 years,
 * the growth rate would be (200 - 100) * (1 / 5) = 100 * 0.2 = 20.0000.
 *
 * Complete the code to solve the exercise.
 */
fun calculateGrowthRate(initialPopulation: Int, finalPopulation: Int, timeInYears: Int): Double {
/**
 * A biologist wants to calculate the growth rate of a population of organisms.
 * The biologist knows the initial population, the final population, and the time span in years.
 *
 * Your task is to complete the code below that calculates the growth rate using the given inputs.
 *
 * The growth rate is calculated as the multiplication of the following two formulas:
 * 1. The change in population size: final population minus initial population
 * 2. The reciprocal of the time span: 1 divided by the time span in years
 *
 * The result should be rounded to 4 decimal places.
 *
 * For example, if the initial population is 100, final population is 200, and time span is 5 years,
 * the growth rate would be (200 - 100) * (1 / 5) = 100 * 0.2 = 20.0000.
 *
 * Complete the code to solve the exercise.
 */
fun calculateGrowthRate(initialPopulation: Int, finalPopulation: Int, timeInYears: Int): Double {

    val growthRate = ((finalPopulation - initialPopulation) * (1.0 / timeInYears)).toDouble()
    return String.format("%.4f", growthRate).toDouble()
}