import java.util.Scanner; public class Products { static String exit = "ÐÐÐÐРШÐТЬ"; public static void calc(int people) { String product; String allProducts = ""; float costPrice; float sumForall = 0.00f; String close; while (true) { Scanner scanner2 = new Scanner(System.in); System.out.println("ÐведиÑе название ÑоваÑа"); product = scanner2.nextLine(); System.out.println("Ð¢Ð¾Ð²Ð°Ñ " + product + " добавлен в ÑÑÑÑ"); System.out.println("ÐведиÑе ÑÑоимоÑÑÑ ÑоваÑа в ÑоÑмаÑе: 'ÑÑбли.копейки' [пÑÐ¸Ð¼ÐµÑ - 10.45, 11.40]"); if (scanner2.hasNextFloat()) { costPrice = scanner2.nextFloat(); if (costPrice > 0) { sumForall = sumForall + costPrice; allProducts = allProducts + product + "\n"; String sufForOne = Calculator.complete(costPrice); String anotherOne = "ÐÑ Ð´Ð¾Ð±Ð°Ð²Ð¸Ð»Ð¸: %s за %.2f%s\n"; System.out.printf(anotherOne, product, costPrice, sufForOne); System.out.println("ÐведиÑе лÑбой Ñимвол, еÑли Ñ Ð¾ÑиÑе добавиÑÑ ÑоваÑ. РпÑоÑивном ÑлÑÑае введиÑе:'ÐÐÐÐРШÐТЬ'"); close = scanner2.next(); if (close.equalsIgnoreCase(exit)) { break; } } else { System.out.println("СÑмма Ñказана невеÑно"); } } else { System.out.println("ÐекоÑÑекÑнÑй ÑоÑÐ¼Ð°Ñ ÑÑоимоÑÑи ÑоваÑа. ÐобÑобÑйÑе ввеÑÑи ÑÑÐ¼Ð¼Ñ ÐµÑÑ Ñаз!"); } } String suf = Calculator.complete(sumForall); float forOneguest = sumForall/ people; String lastSuf = Calculator.complete(forOneguest); System.out.println("ÐÑ ÐºÑпили:\n" + allProducts + "Ðа " + String.format("%.2f", sumForall) + suf); System.out.println("ÐаждÑй из гоÑÑей должен заплаÑиÑÑ: " + String.format("%.2f", forOneguest) + lastSuf); System.out.println("СпаÑибо,ÑÑо воÑполÑзовалиÑÑ Ð½Ð°Ñим ÐалÑкÑлÑÑоÑом - ÑÑÑÑÑиком!"); } }