Sunday, September 25, 2016

// // Leave a Comment

Java Population Projection Calculator

The program below is the answer to Liang's Introduction to Java Programming (9th Edition) Chapter 1 Exercise 1.11.


/**
 *
 * @Author: Aghatise Osazuwa
 * Website: www.cscprogrammingtutorials.com
 *
 * Exercise 1.11 - Population Projection
 *
 */ 

import java.util.Scanner;

public class PopulationProjection {

    public static void main(String[] args) {
        
                int birth = 7;
  int death = 13;
  int immigrant = 45;
  int currentPopulation = 312032486;
  int year = 365;
  int yearlyBirths = (((60 * 60 * 24 * year) / birth));
  int yearlyDeaths = (((60 * 60 * 24 * year) / death));
  int yearlyImmigrants = (((60 * 60 * 24 * year) / immigrant));
  int yearlyPopulation = (yearlyBirths + yearlyImmigrants - yearlyDeaths);

  System.out.println("Current Year Population = " + currentPopulation);
  System.out.println("Next Year's Population = "
    + (currentPopulation + yearlyPopulation));
  System.out.println("Next Two Year's Population = "
    + (currentPopulation + (yearlyPopulation * 2)));
  System.out.println("Next Three Year's Population = "
    + (currentPopulation + (yearlyPopulation * 3)));
  System.out.println("Next Four Year's Population = "
    + (currentPopulation + (yearlyPopulation * 4)));
  System.out.println("Next Five Year'ss Population = "
    + (currentPopulation + (yearlyPopulation * 5)));
    }
}

Click here to see other solutions to Introduction to Java Programming.

0 comments:

Post a Comment


DISCLAIMER: Opinions expressed in comments are those of the comment writers alone and does not reflect or represent the views of the post author. We reserve the right to delete any post deemed inappropriate or offensive and/or spammy. Please do not use abusive words/hate speech.

I Appreciate your valuable Feedback. So, Please DO NOT SPAM - Spam comments will be deleted immediately.

Don't use brand name in name field and you're not allowed to use links in comments unless it's necessary. Such comments will be removed immediately.

Thanks.