Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Map;
- import java.util.Scanner;
- import java.util.TreeMap;
- public class Football {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- TreeMap<String, Integer> statistic = new TreeMap<String, Integer>();
- String command = scanner.nextLine();
- while(!command.equals("End of season")){
- String name = command.split(" - ")[0];
- String goals = command.split(" - ")[1];
- if(statistic.containsKey(name)){
- statistic.put(name, statistic.get(name) + Integer.parseInt(goals));
- }
- else
- {
- statistic.put(name, Integer.parseInt(goals));
- }
- command = scanner.nextLine();
- }
- for (Map.Entry<String,Integer> entry: statistic.entrySet()) {
- System.out.println(entry.getKey() + " -> " + entry.getValue());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement