/**
 * This function calculates the economic growth rate between two given years.
 *
 * @param year1 The starting year.
 * @param year2 The ending year.
 * @param gdp1 The GDP of the starting year.
 * @param gdp2 The GDP of the ending year.
 * @return The economic growth rate between the two years.
 */
fun calculateEconomicGrowth(year1: Int, year2: Int, gdp1: Int, gdp2: Int): String {

    if (year1 < year2) {
        val growthRate = (gdp2 - gdp1) / gdp1 * 100  // Calculate the growth rate
        return when {
            growthRate > 0 -> "The economy has grown by %.2f%% between $year1 and $year2.".format(growthRate)
            growthRate < 0 -> "The economy has shrunk by %.2f%% between $year1 and $year2.".format(Math.abs(growthRate))
            else -> "There is no economic growth between $year1 and $year2."
        }
    } else if (year1 > year2) {
        return "Invalid input: The starting year must be before the ending year."
    }
    return "Invalid input: The starting year and ending year cannot be the same."
}
/**
 * This function calculates the economic growth rate between two given years.
 *
 * @param year1 The starting year.
 * @param year2 The ending year.
 * @param gdp1 The GDP of the starting year.
 * @param gdp2 The GDP of the ending year.
 * @return The economic growth rate between the two years.
 */
fun calculateEconomicGrowth(year1: Int, year2: Int, gdp1: Int, gdp2: Int): String {
/**
 * This function calculates the economic growth rate between two given years.
 *
 * @param year1 The starting year.
 * @param year2 The ending year.
 * @param gdp1 The GDP of the starting year.
 * @param gdp2 The GDP of the ending year.
 * @return The economic growth rate between the two years.
 */
fun calculateEconomicGrowth(year1: Int, year2: Int, gdp1: Int, gdp2: Int): String {

    if (year1 < year2) {
        val growthRate = (gdp2 - gdp1) / gdp1 * 100  // Calculate the growth rate
        return when {
            growthRate > 0 -> "The economy has grown by %.2f%% between $year1 and $year2.".format(growthRate)
            growthRate < 0 -> "The economy has shrunk by %.2f%% between $year1 and $year2.".format(Math.abs(growthRate))
            else -> "There is no economic growth between $year1 and $year2."
        }
    } else if (year1 > year2) {
        return "Invalid input: The starting year must be before the ending year."
    }
    return "Invalid input: The starting year and ending year cannot be the same."
}