The program below is the answer to Liang’s Introduction to Java Programming (9th Edition) Chapter 1 Exercise 1.11.
1 2 |
/**<br /> *<br /> * @Author: Aghatise Osazuwa<br /> * Website: www.cscprogrammingtutorials.com<br /> *<br /> * Exercise 1.11 - Population Projection<br /> *<br /> */ <br /><br />import java.util.Scanner;<br /><br />public class PopulationProjection {<br /><br /> public static void main(String[] args) {<br /> <br /> int birth = 7;<br /> int death = 13;<br /> int immigrant = 45;<br /> int currentPopulation = 312032486;<br /> int year = 365;<br /> int yearlyBirths = (((60 * 60 * 24 * year) / birth));<br /> int yearlyDeaths = (((60 * 60 * 24 * year) / death));<br /> int yearlyImmigrants = (((60 * 60 * 24 * year) / immigrant));<br /> int yearlyPopulation = (yearlyBirths + yearlyImmigrants - yearlyDeaths);<br /><br /> System.out.println("Current Year Population = " + currentPopulation);<br /> System.out.println("Next Year's Population = "<br /> + (currentPopulation + yearlyPopulation));<br /> System.out.println("Next Two Year's Population = "<br /> + (currentPopulation + (yearlyPopulation * 2)));<br /> System.out.println("Next Three Year's Population = "<br /> + (currentPopulation + (yearlyPopulation * 3)));<br /> System.out.println("Next Four Year's Population = "<br /> + (currentPopulation + (yearlyPopulation * 4)));<br /> System.out.println("Next Five Year'ss Population = "<br /> + (currentPopulation + (yearlyPopulation * 5)));<br /> }<br />}<br /> |
Click here to…