package bill; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Bill { public static void main(String[] args) { int totalPrice = 0; int bearNumber = 0; char ch1 = (char)44; char ch2 = (char)45; char[] splitSign = {ch1, ch2}; try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))){ while(true){ String line = br.readLine(); if (line != null && line.length() == 0){ throw new IOException("chyba"); } if (line.substring(0,1).equals("|")){ bearNumber += line.length(); } else{ String[] priceLine = line.split(new String(splitSign)); int price = Integer.parseInt(priceLine[0]); int count = 1; if (priceLine.length == 2){ count = priceLine[1].length(); } totalPrice += price*count; } } } catch(IOException ioe){ totalPrice += bearNumber * 42; totalPrice = (int)Math.ceil((double)totalPrice/10)*10; System.out.println(Integer.toString(totalPrice) + new String(splitSign)); } } }