vstoyanov

Вход и изход от конзолата 6

May 14th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.24 KB | None | 0 0
  1. import org.omg.CORBA.MARSHAL;
  2. import org.omg.Messaging.SYNC_WITH_TRANSPORT;
  3.  
  4. import java.lang.reflect.Array;
  5. import java.util.Scanner;
  6.  
  7. public class Main {
  8.  
  9.     public static void main(String[] args) {
  10.         Scanner scanner=new Scanner (System.in);
  11.                
  12.         long population=Long.parseLong(scanner.nextLine());
  13.         int periodYears=Integer.parseInt(scanner.nextLine());
  14.         int bornPer120Second= Integer.parseInt(scanner.nextLine());
  15.         int deathPer100Second=Integer.parseInt(scanner.nextLine());
  16.         int emigrantPer40Second=Integer.parseInt(scanner.nextLine());
  17.  
  18.         double bornPerSecond=bornPer120Second/120;
  19.         double deathPerSecond=deathPer100Second/100;
  20.         double emigrantPerSecond=emigrantPer40Second/40;
  21.  
  22.         double diffPerSecond=(bornPerSecond+emigrantPerSecond)-deathPerSecond;
  23.  
  24.  
  25.         if(diffPerSecond>0){
  26.            
  27.             double diff=(diffPerSecond*60*60*24*365)*periodYears;
  28.            
  29.             population+=diff;
  30.             System.out.println(population);
  31.            
  32.         }else {
  33.             double diff=(diffPerSecond*60*60*24*365)*periodYears;
  34.  
  35.             population-=diff;
  36.             System.out.println(population);
  37.         }
  38.        
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment