import java.util.Scanner; public class Calculator { public static void calculator(int delitel) { Scanner scannerProduct = new Scanner(System.in); Product productAll = new Product(); while (true) { System.out.println("ÐведиÑе название ÑоваÑа"); String product = scannerProduct.next(); String and = "ÐавеÑÑиÑÑ"; if (product.equalsIgnoreCase(and)) { break; } System.out.println("ÐведиÑе ÑÑоимоÑÑÑ ÑоваÑа (ÑÑбли.копейки)"); Float price = cost(); productAll.allProduct = productAll.allProduct + "\n" + product ; productAll.allPrice = productAll.allPrice + price; System.out.println("Ð¢Ð¾Ð²Ð°Ñ Ð´Ð¾Ð±Ð°Ð²Ð»ÐµÐ½, Ñ Ð¾ÑиÑе добавиÑÑ ÐµÑе ÑÐ¾Ð²Ð°Ñ ? \n ÐÑли неÑ, введиÑе ÐºÐ¾Ð¼Ð°Ð½Ð´Ñ \"ÐавеÑÑиÑÑ\""); String answer = scannerProduct.next(); if (answer.equalsIgnoreCase(and)) { break; } } float personPrice = productAll.allPrice / delitel; String personPriceString = String.format("%.2f", personPrice); int personPriceInteger = (int) personPrice; String rub = PrintRub.getStringRub(personPriceInteger); System.out.println("ÐобавленнÑе ÑоваÑÑ:" + productAll.allProduct + "\n" + "СÑмма к оплаÑе Ð´Ð»Ñ ÐºÐ°Ð¶Ð´Ð¾Ð³Ð¾ Ñеловека - " + personPriceString + " " + rub); } //введение ÑÐµÐ½Ñ public static float cost() { Scanner scanner = new Scanner(System.in); float price = 0.0f; try { String value = scanner.next().trim(); price = Float.parseFloat(value); int pointPosition = value.indexOf('.'); if (!(pointPosition == -1 || value.length() - 1 - pointPosition <= 2)) { System.out.println("Ðведено некоÑÑекÑное знаÑение, попÑобÑйÑе еÑе."); price = cost(); } if (price < 0) { System.out.println("Ðведено некоÑÑекÑное знаÑение, попÑобÑйÑе еÑе."); price = cost(); } } catch (Exception e) { System.out.println("Ðведено некоÑÑекÑное знаÑение, попÑобÑйÑе еÑе."); price = cost(); } return price; } }