import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int countPersons; while (true) { System.out.println("Ðа ÑколÑÐºÐ¸Ñ Ñеловек Ð½ÐµÐ¾Ð±Ñ Ð¾Ð´Ð¸Ð¼Ð¾ ÑазделиÑÑ ÑÑÑÑ?"); if (scanner.hasNextInt()) { countPersons = scanner.nextInt(); scanner.nextLine(); if (countPersons > 1) { break; } } else { scanner.next(); } System.out.println("ÐÑо некоÑÑекÑное знаÑение. ÐопÑобÑем еÑе Ñаз?"); } Calculator calculator = new Calculator(countPersons); while (true) { System.out.println("ÐведиÑе наименование ÑоваÑа:"); String name = scanner.nextLine(); float price; while (true) { System.out.println("ÐведиÑе ÑÑоимоÑÑÑ ÑоваÑа:"); if (scanner.hasNextFloat()) { price = scanner.nextFloat(); scanner.nextLine(); if (price > 0) { break; } } else { scanner.next(); } System.out.println("ÐавеÑное Ð²Ñ Ð¾ÑиблиÑÑ Ð² ÑÑоимоÑÑи. ÐопÑобÑйÑе еÑе Ñаз."); } Good good = new Good(name, price); calculator.addGood(good); System.out.println("Ð¢Ð¾Ð²Ð°Ñ ÑÑпеÑно добавлен."); System.out.println("ХоÑиÑе добавиÑÑ ÐµÑе ÑоваÑ? ÐведиÑе \"ÐавеÑÑиÑÑ\" Ð´Ð»Ñ Ð¾ÐºÐ¾Ð½ÑаниÑ."); String command = scanner.nextLine(); if (command.equalsIgnoreCase("завеÑÑиÑÑ")) { break; } } scanner.close(); System.out.println("ÐобавленнÑе ÑоваÑÑ:\n"); System.out.println(calculator.names); Formatter formatter = new Formatter(); System.out.println("ÐаждÑй Ñеловек должен заплаÑиÑÑ " + formatter.getFormattedSum(calculator.sumByPerson())); } }