Write it in program C The town of Rien. Ohio currently has a population 9.870. D
ID: 3677401 • Letter: W
Question
Write it in program C The town of Rien. Ohio currently has a population 9.870. Due to the recent boom in craft breweries in the town, the population has been growing at a rate of 10% per year. The city fathers are concerned about what will happen when the town reaches 30.000 people and the strain that this type of population will put on the public utilities etc. You are to write a program that uses a loop to compute in what year Rien will reach 30.000 people. But you immediately realize that if you made the program more general, allowing a community to enter their current population and their Target" population, they could also use this software. So you are to have the user enter the current year, the current population and target population. It will then display the population for each year, terminating when the target population has been reached or exceeded. (Note that population growth is like compound interest, the "interest" is computed as a percentage of the larger population at the end of each year: pop = pop + pop*growth_r;) It looks something like this: Your program should have a comment block at the top of the program which includes your name and some information about the program. It should work for any year or populationExplanation / Answer
population.c
#include <stdio.h>
int main()
{
int year;
long population,targetPopulation;
double growthRate;
printf("Welcome to Population Projector ");
printf(" Begin by entering the current year => ");
scanf("%d",&year);
printf(" Now enter your towns's current population => ");
scanf("%ld",&population);
printf(" Enter the expected population growth as a percentage => ");
scanf("%lf",&growthRate);
printf(" Now enter the target population => ");
scanf("%ld",&targetPopulation);
printf(" ");
while(population<=targetPopulation)
{
printf("%d %ld ",year,population);
population=population+population*growthRate/100;
year++;
if(population>=targetPopulation)
{
break;
}
}
printf("In the year %d you will exceed your target of %ld with a population of %ld",year,targetPopulation,population);
return 0;
}
sample output
Welcome to Population Projector
Begin by entering the current year => 2016
Now enter your towns's current population => 10000
Enter the expected population growth as a percentage => 12
Now enter the target population => 48000
2016 10000
2017 11200
2018 12544
2019 14049
2020 15734
2021 17622
2022 19736
2023 22104
2024 24756
2025 27726
2026 31053
2027 34779
2028 38952
2029 43626
In the year 2030 you will exceed your target of 48000 with a population of 48861
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.