// 2024-03-14 Rachel Lydia Rand // Population Reduction Projector // A C# console app Console.WriteLine("Hello, World!"); string numberFormat = "#,##0"; decimal averageLifespan = 80; decimal currentPopulation = 8000000000; decimal startingPopulationByYear = currentPopulation / averageLifespan; Console.WriteLine("currentPopulation = " + currentPopulation.ToString(numberFormat)); Console.WriteLine("startingPopulationByYear = " + startingPopulationByYear.ToString(numberFormat)); decimal currentReplacementRate = 1M; decimal newReplacementRate = currentReplacementRate / 4; Console.WriteLine(""); Console.WriteLine("newReplacementRate = " + newReplacementRate.ToString()); int numOfYearsToProject = 300; int yearsOfLowerBirthrate = 40; int averageAgeOfChildbirth = 30; decimal runningPopulation = currentPopulation; int startingYear = 2025; List NumberOfBirthsInYearYear = new List(); List NumberOfBirthsInYear = new List(); for(int a = startingYear; a < startingYear + numOfYearsToProject; a++) { decimal decreaseAmount = 0; decimal increaseAmount = 0; // deaths if (a < startingYear + averageLifespan) { decreaseAmount = startingPopulationByYear; } else { for(int b = 0; b < NumberOfBirthsInYearYear.Count; b++) { if (NumberOfBirthsInYearYear[b] == a - averageLifespan) { decreaseAmount = NumberOfBirthsInYear[b]; } } } // births if(a < startingYear + averageAgeOfChildbirth) { increaseAmount = startingPopulationByYear * newReplacementRate; } else { for (int b = 0; b < NumberOfBirthsInYearYear.Count; b++) { if (NumberOfBirthsInYearYear[b] == a - averageAgeOfChildbirth) { if (a < startingYear + yearsOfLowerBirthrate) { // still having less births increaseAmount = NumberOfBirthsInYear[b] * newReplacementRate; } else { // back to normal replacement rate increaseAmount = NumberOfBirthsInYear[b] * currentReplacementRate; } } } } runningPopulation -= decreaseAmount;//deaths this year runningPopulation += increaseAmount;//births this year Console.WriteLine("Year = " + a.ToString() + " | totalPopulation = " + runningPopulation.ToString(numberFormat) + " | decreaseAmount = " + decreaseAmount.ToString(numberFormat) + " | increaseAmount = " + increaseAmount.ToString(numberFormat) + "
"); NumberOfBirthsInYearYear.Add(a); NumberOfBirthsInYear.Add(increaseAmount); } Console.ReadLine();