Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Exercice;
- import java.util.*;
- public class MinerTask_06 {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- Map<String,Integer> resources=new LinkedHashMap<>();
- String input;
- int count = 0;
- while (!"stop".equals(input=scanner.nextLine())){
- if (count%2==0){
- if (!resources.containsKey(input)){
- resources.put(input,scanner.nextInt());
- }else {
- resources.put(input,resources.get(input)+scanner.nextInt());
- }
- }
- count++;
- }
- for (Map.Entry<String,Integer> kvp : resources.entrySet()){
- System.out.println(String.format(
- "%s -> %d",kvp
- .getKey(),kvp.getValue()
- ));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement