5.41 exercise Visual C#:How to Program (World Population Growth) World population has grown considerably over the centuries. Continued growth could eventually challenge the limits of breathable air, drinkable water, arable cropland and other limited resources. There's evidence that growth has been slowing in recent years and that world population could peak sometime this century, then start to decline. For this exercise, research world population growth issues online. Be sure to investigate various viewpoints. Get estimates for the current world population and its growth rate (the percentage by which it is likely to increase this year). Write a program that calculates world population growth each year for the next 75 years, using the simplifying assumption that the current growth rate will stay constant. When displaying the results, the first column should display the year from year 1 to year 75. The second column should display the anticipated world population at the end of that year. The third column should display the numerical increase in the world population that would occur that year. Using your result, determine the year in which the population would be double what it is today, if this year's growth rate were to persist. (Hint: Use double variables because int variables can store values only up to approximately two billion. Display the double values using the format F0, which displays the values rounded to the closest whole number - 0 means no digits to the right of the decimal point.)
C# Program:
using System;
public class Program
{
public static void Main()
{
Double startingPopulation,
currentPopulation, growthRate, newPopulation, difference;
//Reading Current population
Console.Write("\n Enter Current
Population: ");
currentPopulation =
Double.Parse(Console.ReadLine());
//Assigning to Starting
population
startingPopulation =
currentPopulation;
//Reading Growth Rate
Console.Write("\n Enter Population
Growth Rate: ");
growthRate =
Double.Parse(Console.ReadLine());
int doubleYear = 0;
//Printing header
Console.WriteLine("\n Year \t
Anticipated Population \t Increase in Population \n");
//Iterating for 75 years
for(int i=1; i<=75; i++)
{
//Calculating
new population
newPopulation =
currentPopulation + (currentPopulation * (growthRate /
100.0));
//Calculating
difference
difference =
newPopulation - currentPopulation;
//Printing
values
Console.WriteLine(" {0:n0} \t\t\t {1:n0} \t\t\t {2:n0} ", i,
newPopulation, difference);
//Finding year
in which population is doubled
if(doubleYear ==
0 && (newPopulation >= (2*startingPopulation)))
{
doubleYear = i;
}
//Updating
population
currentPopulation = newPopulation;
}
//Printing year in which population
is doubled
Console.WriteLine("\n Year in which
population doubled is {0} \n", doubleYear);
}
}
____________________________________________________________________________________________
Sample Output:
5.41 exercise Visual C#:How to Program (World Population Growth) World population has grown considerably over the...
This exercise uses the population growth model. The population of the world was 7.1 billion in 2013, and the observed relative growth rate was 1.1% per year. (a) Estimate how long it takes the population to double. (Round your answer to two decimal places.) yr (b) Estimate how long it takes the population to triple. (Round your answer to two decimal places.) yr
Write a program to help answer questions like the following: Suppose the species Klingon ox has a population of 100 and a growth rate of 15 percent, and the species elephant has a population of 10 and a growth rate of 35 percent. How many years will it take for the elephant population to exceed the Klingon ox population? You can assume that this will happen within 10 years. Use the version of the class Species from Sakai’s Week 7...