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

Using Java (Population projection) The U.S. Census Bureau projects popopulation

ID: 3663963 • Letter: U

Question

Using Java

(Population projection) The U.S. Census Bureau projects popopulation based on the following assumptions: One birth every 7 seconds One death every 13 seconds One new immigrant every 45 seconds Write a program to display the population for each of the next five years. Assume the current population is 312,032,486 and one year has 365 days. Hint: In Java, if two integers perform division, the result is an integer. The fractional part is truncated. For example, 5/4 is 1 (not 1.25) and 10/4 is 2 (not 2.5). To get an accurate result with the fractional part, one of the values involved in the division must be a number with a decimal point. For example, 5.0/4 is 1.25 and 10/4.0 is 2.5.

use consistent indentation, spacing and bracing style throughout your program add a comment that explains what the program does add a multi-line comment with your name and the course name at the top of your file

Explanation / Answer

Program:

public class Population {
   public static void main(String arg[])
   {
       int population=312032486;
       int seconds=365*24*60*60;
       System.out.println("Current Population : "+ population);
       for(int i=0;i<5;i++)
       {
           population-= seconds/26; //it is calculating population , in every 7 second one born and 45 second
                                   //and one dead in 13 seconds so that no increment in population in population
                                   // in every 26 second , population is reduced by 1
           System.out.println("Population after "+(i+1)+" year : "+ population); //print population of every month
       }
   }

Result:

Current Population : 312032486
Population after 1 year : 310819563
Population after 2 year : 309606640
Population after 3 year : 308393717
Population after 4 year : 307180794
Population after 5 year : 305967871

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