Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The town of Rien. Ohio currently has a population 9.870. Due to the recent boom

ID: 3675896 • Letter: T

Question

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 d 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: If 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 population. When you are happy with your program run a script file, showing the input that t have given you above AND a second running with some different input. Submit to Blackboard both your source code and script file that you have created using the numbers given to you by your TA.

Explanation / Answer

/* C program to find out
   in which year current population
   exceeds the target population
*/

#include <stdio.h>

int main ()
{
   int year;
   float current_population;
   float percentage;
   int target_population;
   printf("Welcome to Population Projector. ");
   printf("Begin by entering the current year => ");
   scanf("%d",&year);
   printf("Now enter your town's current Population => ");
   scanf("%f",&current_population);
   printf("Enter the expected population growth as a percentage => ");
   scanf("%f",&percentage);
   printf("Now enter the target population => ");
   scanf("%d",&target_population);
   printf(" ");

   printf(" %d %d ",year,(int)current_population);
   while(current_population < target_population)
   {
       year++;
       current_population = (int) ( current_population *(1+ percentage/100));
       if(current_population < target_population) printf(" %d %d ",year,(int)current_population);
      
   }

   printf("In the year %d you will exceed your target of %d with a population of %d ",year, target_population, (int)current_population );
   return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at drjack9650@gmail.com
Chat Now And Get Quote