Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.LinkedHashMap;
- import java.util.Scanner;
- public class MinerTasks {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- LinkedHashMap<String, Integer> quanity = new LinkedHashMap<>();
- String input = "";
- while (!"stop".equals(input = scanner.nextLine())) {
- String resourse = input;
- int material = Integer.parseInt(scanner.nextLine());
- if (!quanity.containsKey(resourse)) {
- quanity.put(resourse, material);
- } else {
- quanity.put(resourse, quanity.get(resourse) + material);
- }
- }
- quanity.forEach((key, value) -> {
- System.out.println(String.format("%s -> %d", key, value));
- });
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement