import java.util.Scanner; public class Calculator { public int scannerNumber() { int number = 0; while (number <= 1) { Scanner in = new Scanner(System.in); System.out.print("УкажиÑе на ÑколÑко Ñеловек Ð½ÐµÐ¾Ð±Ñ Ð¾Ð´Ð¸Ð¼Ð¾ ÑазделиÑÑ ÑÑеÑ: "); if (in.hasNextInt()) { number = in.nextInt(); } } return number; } public boolean checkProduct(String[] scannerProduct) { if (scannerProduct.length != 2) { return false; } float f; try { f = Float.parseFloat(scannerProduct[1]); if (f <= 0) { return false; } } catch (NumberFormatException e) { return false; } return true; } public Product scannerProducts(Product prod) { while (true) { Scanner sc = new Scanner(System.in); System.out.println("ÐведиÑе ÑÐ¾Ð²Ð°Ñ Ð¸ его ÑÑоимоÑÑÑ ÑеÑез пÑобел:"); String productAndCost = sc.nextLine(); String[] productAndCostArray = productAndCost.split(" "); if (checkProduct(productAndCostArray)) { float price = Float.parseFloat(productAndCostArray[1]); prod.addProduct(productAndCostArray[0], price); System.out.println("ÐÑодÑÐºÑ ÑÑпеÑно добавлен"); } else { System.out.println("ÐевеÑнÑй ÑоÑÐ¼Ð°Ñ Ð´Ð°Ð½Ð½ÑÑ , пÑодÑÐºÑ Ð½Ðµ бÑл добавлен"); } System.out.println("ÐÑли Ñ Ð¾ÑиÑе добавиÑÑ ÐµÑÑ Ð¾Ð´Ð¸Ð½ пÑодÑÐºÑ Ð²Ð²ÐµÐ´Ð¸Ñе лÑбой Ñимвол или \"ÐавеÑÑиÑÑ\""); String newProduct = sc.nextLine(); if (newProduct.equalsIgnoreCase("завеÑÑиÑÑ")) { break; } } return prod; } }