Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Problem04;
- import java.util.HashMap;
- import java.util.LinkedHashMap;
- import java.util.Scanner;
- public class PopulationCounter {
- public static void main(String[] args) {
- Scanner Console = new Scanner(System.in);
- String line = Console.nextLine();
- LinkedHashMap<String, HashMap<String, Long>> Map = new LinkedHashMap<>();
- while (!line.equals("report")) {
- String[] strArray = Console.nextLine().split("\\|+");
- String city = strArray[0];
- String country = strArray[1];
- Long population = Long.parseLong(strArray[2]);
- if (!Map.containsKey(city)) {
- Map.put(city, new LinkedHashMap<>());
- }
- Map.get(city).put(country, population);
- line = Console.nextLine();
- }
- System.out.println(Map);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement