import java.util.Scanner; public class calc { public static void input(int numberOfFriends) { Scanner scanner = new Scanner(System.in); String roubles; String[] product = new String[100]; int numbersOfProduct = 0; float sum = 0; float price; for (int i = 0; i < product.length; i++) { System.out.println("ÐведиÑе название блÑда:"); product[i] = scanner.next(); do { System.out.println("ÐведиÑе его ÑÑоимоÑÑÑ Ñ ÐºÐ¾Ð¿ÐµÐ¹ÐºÐ°Ð¼Ð¸ (в ÑоÑмаÑе 0,00): "); while (!scanner.hasNextFloat()) { System.out.println("ÐÑ Ð²Ð²ÐµÐ»Ð¸ не ÑиÑло! ÐовÑоÑиÑе ввод ÑенÑ:"); scanner.next(); } price = scanner.nextFloat(); } while (price <= 0); sum += price; numbersOfProduct++; System.out.println("Ðобавлено!\n ÐобавиÑе еÑÑ Ð±Ð»Ñдо? ÐÐµÑ - введиÑе ÐавеÑÑиÑÑ. Ðа - введиÑе лÑбой Ñимвол"); String answer = scanner.next(); if (answer.equalsIgnoreCase("завеÑÑиÑÑ")) { break; } } printAllProducts(numbersOfProduct,product); roubles = getRubleAddition((int) sum / numberOfFriends); System.out.printf("\nС каждого дÑÑга по %.2f %s\n", sum / numberOfFriends, roubles); } private static void printAllProducts(int numbersOfProduct, String[] product){ System.out.println("\n\"ÐобавленнÑе ÑоваÑÑ:\" "); for (int j = 0; j < numbersOfProduct; j++) { if (product[j].isEmpty()) { break; } else { System.out.println(product[j]); } } } public static String getRubleAddition(int number){ float predPosCifra = number % 100 / 10; if (predPosCifra == 1) { return "ÑÑблей"; } switch (number % 10) { case 1: return "ÑÑблÑ"; case 2: case 3: case 4: return "ÑÑблÑ"; default: return "ÑÑблей"; } } }