Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public class FootballMatch {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- HashMap<String, Integer> goals = new HashMap<String, Integer>();
- while(true) {
- String[] input = scanner.nextLine().split(" - ");
- if(input[0].equalsIgnoreCase("end of season")) {
- break;
- }
- if(goals.containsKey(input[0])) {
- goals.put(input[0], goals.get(input[0])+Integer.parseInt(input[1]));
- } else {
- goals.put(input[0], Integer.parseInt(input[1]));
- }
- }
- ArrayList<String> keys = new ArrayList<String>(goals.keySet());
- Collections.sort(keys);
- for(String s : keys) {
- System.out.println(s+" -> "+goals.get(s));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement