import java.util.Scanner; public class Main { public static void main(String[] args) { System.out.println("ÐÑивеÑÑÑвÑÑ!\nÐа ÑколÑко пеÑÑон желаеÑе ÑазделиÑÑ ÑÑÑÑ ?"); int numberPerson = checkNumberPersons(); Dish dish = new Dish(); System.out.println(dish.addDish()); float paymentPerson = dish.allCost / (float) numberPerson; System.out.printf("РоплаÑе Ñ ÐºÐ°Ð¶Ð´Ð¾Ð¹ пеÑÑонÑ: %.2f " + rublesCases(dish.allCost, numberPerson), paymentPerson); } public static int checkNumberPersons() { Scanner scanner = new Scanner(System.in); int numberPerson; while (true) { if (scanner.hasNextInt()) { numberPerson = Integer.parseInt(scanner.nextLine()); if (numberPerson <= 1) { System.out.println("ÐекоÑÑекÑное знаÑение"); } else { break; } } else { System.out.println("ÐШÐÐÐÐ!\nÐекоÑÑекÑное знаÑение"); scanner.nextLine(); } } return numberPerson; } public static String rublesCases(float cost, int numberPerson) { float allRubles = cost / numberPerson; int ruble = (int) (allRubles % 100); String cases; if (ruble == 1) { cases = "ÑÑблÑ"; } else if (ruble >= 2 && ruble <= 4) { cases = "ÑÑблÑ"; } else if (ruble >= 11 && ruble <= 14) { cases = "ÑÑблей"; } else { cases = "ÑÑблей"; } return cases; } }