C#

Develop a form that allows the user to project the population of your city for a specific number of years and growth rate. Allow the user to specify the current year's population, the number of years and the annual growth rate. Use a FOR loop to compute and display each year, starting with the current year and the corresponding population

State any assumption made.

Respuesta :

Answer:

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

namespace Population

{

class Program

{

static void Main(string[] args)

{

int currentYearPopulation,numberYears;

double growthRate,population;

population = 0.0;

Console.Write("Enter the current year population: ");

currentYearPopulation = Convert.ToInt32((Console.ReadLine()));

Console.Write("\nEnter the number of years: ");

numberYears = Convert.ToInt32(Console.ReadLine());

Console.Write("\nEnter the annual growth rate: ");

growthRate = Convert.ToDouble(Console.ReadLine());

population = currentYearPopulation;

Console.WriteLine("\n\nYear\tPopulation");

Console.WriteLine("------------------------");

for (int i = 1; i <= numberYears; i++)

{

Console.Write(i+"\t");

Console.WriteLine(Math.Round(population));

population = population + population * (growthRate/100);

}

Console.ReadKey();

}

}

}