public class Main { private static final int MIN_PEOPLE_COUNT = 2; private static final String FINISH_COMMAND = "ÐавеÑÑиÑÑ"; static int readPersonsCount() { int personsCount; while (true) { personsCount = TerminalReader.readInt( String.format( "Ðа ÑколÑÐºÐ¸Ñ Ñеловек ÑазделиÑÑ ÑÑÐµÑ ? (знаÑение должно бÑÑÑ >=%d)", MIN_PEOPLE_COUNT ) ); if (personsCount < MIN_PEOPLE_COUNT) { System.out.printf( "ÐнаÑение должно бÑÑÑ >=%d !%n", MIN_PEOPLE_COUNT ); } else { break; } } return personsCount; } public static void main(String[] args) { int personsCount = readPersonsCount(); Calculator calculator = new Calculator(personsCount); while (true) { Product product = Product.read(); calculator.add(product); String command = TerminalReader.readString("ХоÑиÑе добавиÑÑ ÐµÑе ÑÐ¾Ð²Ð°Ñ ? ÐÑли неÑ, введиÑе \"завеÑÑиÑÑ\"."); if (command.equalsIgnoreCase(FINISH_COMMAND)) { break; } } calculator.showAllProducts(); calculator.showSumByPerson(); } }