import java.util.Scanner; public class Main { static Scanner scanner = new Scanner(System.in); public static void main(String[] args) { System.out.print("ÐобÑо пожаловаÑÑ Ð² ÑиÑÑÐµÐ¼Ñ ÑовмеÑÑнÑÑ Ð·Ð°ÐºÑпок!\n"); getPeopleCount(); getGoods(); Calculator.printCheck(); } static void getPeopleCount() { int peopleCount; System.out.print("СколÑко Ñеловек бÑÐ´ÐµÑ Ð¿ÑиобÑеÑаÑÑ ÑоваÑÑ?\n"); while (true) { if (scanner.hasNextInt()) { int input = scanner.nextInt(); if (input >= 2) { peopleCount = input; break; } else { System.out.print("ÐÑибка: невеÑнÑй ввод!\n"); } } else { System.out.print("ÐÑибка: невеÑнÑй ввод!\n"); scanner.next(); } } Calculator.peopleCount = peopleCount; } static void getGoods() { String goodLabel; double goodPrice; System.out.print("ÐведиÑе название ÑоваÑа:\n"); goodLabel = scanner.next(); while (true) { System.out.print("ÐведиÑе ÑÑоимоÑÑÑ ÑоваÑа [" + goodLabel + "] в ÑоÑмаÑе: \"ÑÑб.коп\", напÑÐ¸Ð¼ÐµÑ [10.45, 11.40]:\n"); while (true) { if (scanner.hasNextDouble()) { double input = scanner.nextDouble(); if (isRightFormat(input)) { goodPrice = input; break; } else { System.out.print("ÐÑибка: невеÑнÑй ввод!\n"); } } else { System.out.print("ÐÑибка: невеÑнÑй ввод!\n"); scanner.next(); } } Calculator.addNewGood(new Good(goodLabel, goodPrice)); System.out.print("ÐведиÑе название ÑоваÑа, или введиÑе \"ÐавеÑÑиÑÑ\", ÑÑÐ¾Ð±Ñ Ð·Ð°ÐºÐ¾Ð½ÑиÑÑ:\n"); String input = scanner.next(); if (input.equalsIgnoreCase("ÐавеÑÑиÑÑ")) { break; } else { goodLabel = input; } } } static boolean isRightFormat (Double d) { String[] splitter = String.valueOf(d).split("[.]"); int l = splitter[1].length(); return (d > 0) && (l <= 2); } }