import java.util.Scanner; public class Main { public static void main(String[] args) { System.out.println("ÐдÑавÑÑвÑйÑе! Ðа ÑколÑко Ñеловек ÑазделиÑÑ ÑÑÑÑ?"); Scanner scanner = new Scanner(System.in); int x = 0; while (true) { try { x = scanner.nextInt(); if (x >= 2) { // еÑли полÑзоваÑÐµÐ»Ñ Ð²Ð²Ð¾Ð´Ð¸Ñ ÐºÐ¾ÑÑекÑное знаÑение System.out.println(); break; } } catch (Exception e) { scanner.next(); } System.out.println("Ðведено некоÑÑекÑное знаÑение, попÑобÑйÑе еÑе."); } Calculator.calculator(x); } // // // public static void calculator(int delitel) { // // Scanner scannerProduct = new Scanner(System.in); // String allProduct = ""; // Float allPrice = 0.0f; // while (true) { // System.out.println("ÐведиÑе название ÑоваÑа"); // String product = scannerProduct.next(); // String and = "ÐавеÑÑиÑÑ"; // if (product.equalsIgnoreCase(and)) { // break; // } // // System.out.println("ÐведиÑе ÑÑоимоÑÑÑ ÑоваÑа (ÑÑбли.копейки)"); // Float price = cost(); // allProduct = allProduct + "\n" + product + ": " + price; // allPrice = allPrice + price; // System.out.println("Ð¢Ð¾Ð²Ð°Ñ Ð´Ð¾Ð±Ð°Ð²Ð»ÐµÐ½, Ñ Ð¾ÑиÑе добавиÑÑ ÐµÑе ÑÐ¾Ð²Ð°Ñ ? \n ÐÑли неÑ, введиÑе ÐºÐ¾Ð¼Ð°Ð½Ð´Ñ \"ÐавеÑÑиÑÑ\""); // String answer = scannerProduct.next(); // if (answer.equalsIgnoreCase(and)) { // break; // } // // } // float personPrice = allPrice / delitel; // String personPriceString = String.format("%.2f", personPrice); // int personPriceInteger = (int) personPrice; // String rub = conjugation(personPriceInteger); // System.out.println("ÐобавленнÑе ÑоваÑÑ:" + "\n" + 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; // } // public static String conjugation(int integer) { // int remainder = integer % 100; // if (remainder >= 11 && remainder <= 14) { // return "ÑÑблей"; // } // remainder = integer % 10; // switch (remainder) { // case 1: // return "ÑÑблÑ"; // case 2: // case 3: // case 4: // return "ÑÑблÑ"; // case 0: // case 5: // case 6: // case 7: // case 8: // case 9: // return "ÑÑблей"; // default: // return "ÑÑблÑ"; // } // // } }