# World Population Growth Calculator in java

Question : (World Population Growth Calculator) Use the web to determine the current world population and the annual world population growth rate. Write an application that inputs these values,then displays the estimated world population after one, two, three, four and five years.

## World Population Growth Calculator in java

``````/*
*       Filename:  WorldPopulationGrowthCalc.java
*
*    Description:  Exercise 2.34 - World Population Growth Calculator
*
*@Author:  Bilal Tahir Khan Meo
*  Website: https://codeblah.com
*
* =====================================================================================
*/
import java.util.Scanner;

public class WorldPopulationGrowthCalc{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);

long population;
double growthRate;

System.out.print("Enter current world population: ");
population = sc.nextLong();

System.out.print("Enter annual world population growth rate: ");
growthRate = sc.nextDouble();

// print growth rate
for(int i=1; i<6; i++, population *= growthRate){
System.out.printf("%d years = %d\n", i, population);
}
}
}
``````

# Java World Population Growth Calculator

``````/**
*
*@Author:  Bilal Tahir Khan Meo
*  Website: https://codeblah.com
*
* Exercise 2.34 - World Population Growth Calculator
* This Program Calculates And Displays The Estimated World Population After One, Two, Three,
* Four And Five Years
*
*/

//Based on data from worldometer World Population clock (worldometers.info/world-population)
//Geohive (www.geohive.com/earth/population_now.aspx)
//US World Population Clock (www.census.gov/popclock)
//Current world population is 7,321,870,923 with an average yearly growth rate of 1.10%

import java.util.Scanner;

public class Ex02_34 {
public static void main (String [] args) {

Scanner input = new Scanner (System.in);

double currentPop;
double growthRate;
double annualPopIncrease;
double estimatedPop;

System.out.print ("Enter Current World Population: ");
currentPop = input.nextLong();
System.out.print ("Enter Annual Population Growth Rate: ");
growthRate = input.nextInt();
annualPopIncrease = (growthRate / 100) * currentPop;
estimatedPop = currentPop + annualPopIncrease;

System.out.println ();

System.out.println("Estimated population after one year:     " + estimatedPop);
System.out.println("Estimated population after two years:    " + estimatedPop + (annualPopIncrease * 2));
System.out.println("Estimated population after three years:  " + estimatedPop + (annualPopIncrease * 3));
System.out.println("Estimated population after four years:   " + estimatedPop + (annualPopIncrease * 4));
System.out.println("Estimated population after five years:   " + estimatedPop + (annualPopIncrease * 5));

}
}``````