Advertisement
another90sm

Untitled

Apr 14th, 2016
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.16 KB | None | 0 0
  1. import java.math.BigDecimal;
  2. import java.util.ArrayList;
  3. import java.util.List;
  4. import java.util.Locale;
  5. import java.util.Scanner;
  6.  
  7. public class DragonAccountant {
  8.  
  9.     public static BigDecimal additionalEvents(String[] events, BigDecimal capital) {
  10.         BigDecimal result = capital;
  11.         for (int i = 3; i < events.length; i++) {
  12.             String[] temp = events[i].split(":");
  13.             switch (temp[0]) {
  14.                 case "Previous years deficit":
  15.                 case "Machines":
  16.                 case "Taxes":
  17.                     result = result.subtract(new BigDecimal(temp[1]));
  18.                     break;
  19.                 case "Product development":
  20.                 case "Unconditional funding":
  21.                     result = result.add(new BigDecimal(temp[1]));
  22.                     break;
  23.             }
  24.         }
  25.         return result;
  26.     }
  27.  
  28.     public static void main(String[] args) {
  29.         Locale.setDefault(new Locale("en", "EN"));
  30.         Scanner scanner = new Scanner(System.in);
  31.         BigDecimal initialCapital = scanner.nextBigDecimal();
  32.         scanner.nextLine();
  33.         long totalHired = 0;
  34.         long totalFired = 0;
  35.         int days = 0;
  36.         int startPosition = 0;
  37.  
  38.         List<Long> hiredPeople = new ArrayList<>();
  39.         //hiredPeople.add(null);
  40.         List<Long> firedPeople = new ArrayList<>();
  41.         //firedPeople.add(null);
  42.         List<BigDecimal> sellaryTable = new ArrayList<>();
  43.         //sellaryTable.add(null);
  44.  
  45.         String[] input = scanner.nextLine().split(";");
  46.  
  47.         while (!input[0].equals("END")) {
  48.             long hired = Long.parseLong(input[0]);
  49.             totalHired += hired;
  50.             hiredPeople.add(days, hired);
  51.  
  52.             long fired = Long.parseLong(input[1]);
  53.             totalFired += fired;
  54.             firedPeople.add(days, fired);
  55.  
  56.             BigDecimal salary = new BigDecimal(input[2]);
  57.             sellaryTable.add(days, salary);
  58.             if (days % 30 == 0) {
  59.  
  60.  
  61.             }
  62.  
  63.  
  64.             initialCapital = additionalEvents(input, initialCapital);
  65.             input = scanner.nextLine().split(";");
  66.             days++;
  67.         }
  68.     }
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement