daily pastebin goal
40%
SHARE
TWEET

Untitled

MoPhreak Mar 20th, 2019 50 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.LinkedHashMap;
  2. import java.util.Scanner;
  3.  
  4. public class MinerTasks {
  5.     public static void main(String[] args) {
  6.         Scanner scanner = new Scanner(System.in);
  7.  
  8.         LinkedHashMap<String, Integer> quanity = new LinkedHashMap<>();
  9.  
  10.         String input = "";
  11.  
  12.         while (!"stop".equals(input = scanner.nextLine())) {
  13.             String resourse = input;
  14.             int material = Integer.parseInt(scanner.nextLine());
  15.  
  16.             if (!quanity.containsKey(resourse)) {
  17.                 quanity.put(resourse, material);
  18.             } else {
  19.                 quanity.put(resourse, quanity.get(resourse) + material);
  20.             }
  21.         }
  22.         quanity.forEach((key, value) -> {
  23.             System.out.println(String.format("%s -> %d", key, value));
  24.         });
  25.  
  26.  
  27.     }
  28. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top