import java.util.*; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); String line; Map> stores = new TreeMap<>(); while (!"Revision".equals(line= scan.nextLine())){ String[] gros = line.split(", "); String store = gros[0]; String product = gros[1]; double price = Double.parseDouble(gros[2]); stores.putIfAbsent(store, new LinkedHashMap<>()); stores.get(store).putIfAbsent(product, price); } // stores.forEach((shop, product) -> { // System.out.println(shop + "->"); // product.forEach((prodName, price) ->{ // System.out.println(String.format("Product: %s, Price: %.1f", prodName, price)); // }); // }); for (String shopName : stores.keySet()) { System.out.println(shopName + "->"); LinkedHashMap products = stores.get(shopName); for (String proName : products.keySet()) { System.out.printf("Product: %s, Price: %.1f\n", proName, products.get(proName)); } } } }