Advertisement
harisjasar

BHPopulation

Mar 9th, 2017
2,934
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. import java.util.Scanner;
  3.  
  4. public class BosniaPopulation {
  5.     public static void main (String [] args) {
  6.  
  7.  Scanner input = new Scanner (System.in);
  8.          
  9.         int currentYear;
  10.         int minutes = 1440 * 365;
  11.         int area;
  12.         double currentPop;
  13.         double newborn;
  14.         double year;
  15.         double death;
  16.         double emigrants;
  17.         int randomYear;
  18.        
  19.         System.out.println("Enter current year: ");
  20.         currentYear = input.nextInt();
  21.        
  22.         System.out.println("Please enter the area size: ");
  23.         area = input.nextInt();
  24.        
  25.         System.out.print ("Enter Current BiH Population: ");
  26.         currentPop = input.nextLong(); //Current Bosnian population is 3,867,055
  27.        
  28.         System.out.print ("Enter number of minutes per every newborn: ");
  29.         newborn = input.nextInt(); //Number of minutes per newborn is 19
  30.        
  31.         System.out.print ("Enter number of minutes per every death: ");
  32.         death = input.nextInt(); //Number of minutes per death is 15
  33.        
  34.         System.out.println("Enter number of minutes per every emigrant: ");
  35.         emigrants = input.nextInt(); //Number of minutes per emigrant is 25
  36.         System.out.println();
  37.        
  38.         year = ((minutes / newborn) - (minutes / death) - (minutes / emigrants));
  39.        
  40.        
  41.    
  42.         System.out.println ("Change in population over the course of next 10 years:");
  43.         System.out.println();
  44.        
  45.         System.out.println("2016: population - " + currentPop + " ppl; " + "density: " + (currentPop / area) + " ppl/sqkm;");
  46.         System.out.println("2017: population - " + (currentPop + year) + " ppl; " + "density: " + ((currentPop + year) / area) + " ppl/sqkm;");
  47.         System.out.println("2019: population - " + (currentPop + (year * 2)) + " ppl; " + "density: " + ((currentPop + (year * 2)) / area) + " ppl/sqkm;");
  48.         System.out.println("2020: population - " + (currentPop + (year * 3)) + " ppl; " + "density: " + ((currentPop + (year * 3)) / area) + " ppl/sqkm;");
  49.         System.out.println("2021: population - " + (currentPop + (year * 4)) + " ppl; " + "density: " + ((currentPop + (year * 4)) / area) + " ppl/sqkm;");
  50.         System.out.println("2022: population - " + (currentPop + (year * 5)) + " ppl; " + "density: " + ((currentPop + (year * 5)) / area) + " ppl/sqkm;");
  51.         System.out.println("2023: population - " + (currentPop + (year * 6)) + " ppl; " + "density: " + ((currentPop + (year * 6)) / area) + " ppl/sqkm;");
  52.         System.out.println("2024: population - " + (currentPop + (year * 7)) + " ppl; " + "density: " + ((currentPop + (year * 7)) / area) + " ppl/sqkm;");
  53.         System.out.println("2025: population - " + (currentPop + (year * 8)) + " ppl; " + "density: " + ((currentPop + (year * 8)) / area) + " ppl/sqkm;");
  54.         System.out.println("2026: population - " + (currentPop + (year * 9)) + " ppl; " + "density: " + ((currentPop + (year * 9)) / area) + " ppl/sqkm;");
  55.         System.out.println("2027: population - " + (currentPop + (year * 10)) + " ppl; " + "density: " + ((currentPop + (year * 10)) / area) + " ppl/sqkm;");
  56.         System.out.println();
  57.        
  58.         System.out.println("If you want to check the number of population in some other year, please type it below: ");
  59.         randomYear = input.nextInt();
  60.        
  61.         while(randomYear > 2152){
  62.             System.out.println("By the year " + randomYear + " Bosnian population is 0.");
  63.             System.out.println("Please try some other year: ");
  64.             randomYear = input.nextInt();
  65.        }
  66.        
  67.         System.out.println();
  68.        
  69.         while(randomYear < 2016){
  70.             System.out.println("Unfortunately system does not have information going back past 2016");
  71.             System.out.println("Please try some other year: ");
  72.             randomYear = input.nextInt();
  73.             System.out.println();
  74.        }
  75.        
  76.         System.out.println();
  77.        
  78.         if  (randomYear >2016 && randomYear <= 2152) {
  79.             System.out.println(randomYear + ": population - " + ((((randomYear - currentYear) * (year)) + currentPop)) + " ppl; " + "density: " + ((((randomYear - currentYear) * (year)) + currentPop) / area) + " ppl/sqkm;");
  80.         }
  81.            
  82.        
  83.         System.out.println();
  84.        
  85.     }
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement