import java.util.Scanner; public class Main { private static final Scanner scanner = new Scanner(System.in); private static Calculator calculator = new Calculator(); public static void main(String[] args) { System.out.println("ÐалÑкÑлÑÑÐ¾Ñ ÑÑеÑа пÑивеÑÑÑвÑÐµÑ Ð²Ð°Ñ. "); int countPerson = getCountPerson(); getProducts(); calculator.printProductList(); calculator.splitCheck(countPerson); } public static int getCountPerson(){ int countPerson; while(true) { System.out.println("ÐведиÑе колиÑеÑÑво Ñеловек. ÐÑполÑзÑйÑе ÑиÑла болÑÑе 1."); String str = scanner.nextLine(); countPerson = str.matches("\\d+") ? Integer.parseInt(str) : 0; if (countPerson > 1) { break; } else { System.out.println("ÐÑ Ð²Ð²ÐµÐ»Ð¸ некоÑÑекÑное знаÑение: " + str + ". ÐведиÑе ÑиÑло болÑÑе 1. ÐопÑобÑйÑе еÑе Ñаз.\n"); } } return countPerson; } public static void getProducts(){ while(true) { System.out.println("ÐведиÑе название ÑоваÑа или ÐºÐ¾Ð¼Ð°Ð½Ð´Ñ 'ÐавеÑÑиÑÑ':"); String strName = scanner.nextLine(); if ( strName.equalsIgnoreCase("завеÑÑиÑÑ")){ break; } else{ System.out.println("ÐведиÑе ÑÑоимоÑÑÑ ÑоваÑа в ÑоÑмаÑе ÑÑ.кк:"); String strPrice = scanner.nextLine(); double price = strPrice.matches("\\d{1,}+(\\.\\d{2}+)") ? Double.parseDouble(strPrice) : -1; if( price >= 0 ){ calculator.add(strName, price); } else{ System.out.println("ÐÑ Ð²Ð²ÐµÐ»Ð¸ некоÑÑекÑнÑÑ ÑÑоимоÑÑÑ ÑоваÑа: " + strPrice + ". Ð¢Ð¾Ð²Ð°Ñ Ð½Ðµ добавлен в ÑпиÑок. ÐопÑобÑйÑе еÑе Ñаз.\n"); } } } } }