import java.util.Scanner; public class Main { public static void main(String[] args) { System.out.println("ÐдÑавÑÑвÑйÑе! Ðа ÑколÑко гоÑÑей ÑазделиÑÑ ÑÑÑÑ?"); int guest; while (true) { Scanner scanner = new Scanner(System.in); if (scanner.hasNextInt()) { guest = scanner.nextInt(); if (guest > 1) { System.out.println("ÐолиÑеÑÑво гоÑÑей " + guest); break; } else if (guest == 1) { System.out.println("СÑÑÑ Ð²ÑÑÑавлен на 1 гоÑÑÑ"); } } else { System.out.println("ÐÑоизоÑла оÑибка"); scanner.reset(); } } String product; float price; float totalPrice = 0; String goods = ""; while (true) { Scanner scanner = new Scanner(System.in); System.out.println("ÐÑбеÑиÑе блÑдо"); product = scanner.nextLine(); scanner.reset(); System.out.println("УкажиÑе ÑенÑ"); if (scanner.hasNextFloat()) { price = scanner.nextFloat(); if (price <= 0) { System.out.println("ÐÑоизоÑла оÑибка"); } else { Scanner scanner1 = new Scanner(System.in); totalPrice = totalPrice + price; goods = goods + product; System.out.println("ÐлÑдо в коÑзине"); System.out.println("ÐобавиÑÑ ÐµÑÑ Ð¸Ð»Ð¸ \"ÐавеÑÑиÑÑ\"?"); String check = scanner1.nextLine(); scanner1.reset(); String complete = "ÐавеÑÑиÑÑ"; if (check.equalsIgnoreCase (complete)) { System.out.println("ÐлÑда в коÑзине:" + "\n"+ goods); String payment = "ÐÑого ÐºÐ°Ð¶Ð´Ð¾Ð¼Ñ Ðº оплаÑе: %.2f %s"; Rouble ending = new Rouble(); System.out.println(String.format(payment, totalPrice / guest, ending.ending(totalPrice/guest))); break; } } } } } } class Rouble { public String ending(double rubles) { int ending = (int) (Math.floor(rubles) % 10); if (((int) (Math.floor(rubles) % 100)) <= 19 && ((int) (Math.floor(rubles) % 100)) >= 11) return "ÑÑблей"; switch (ending) { case 1: return "ÑÑблÑ"; case 2: case 3: case 4: return "ÑÑблÑ"; default: return "ÑÑблей"; } } }