import java.util.Scanner; class Obrabotchiki { static String checkBook = ""; static float cashOut; public static int peopleCountQuestion() { float peopleCount; System.out.println("Ðа ÑколÑÐºÐ¸Ñ Ñеловек Ð½ÐµÐ¾Ð±Ñ Ð¾Ð´Ð¸Ð¼Ð¾ ÑазделиÑÑ ÑÑÑÑ?"); do { Scanner sc = new Scanner(System.in); peopleCount = digitCheck(sc); if (peopleCount < 1) { System.out.println("ÐекоÑÑекÑное знаÑение Ð´Ð»Ñ Ð¿Ð¾Ð´ÑÑÑÑа. ÐведиÑе знаÑение еÑе Ñаз"); } else if (peopleCount == 1) { System.out.println("ÐÐµÑ ÑмÑÑла делиÑÑ ÑÑÑÑ. ÐведиÑе знаÑение еÑе Ñаз"); } else { System.out.printf("ÐÑлиÑно, Ñазделим ÑÑÐµÑ Ð¿Ð¾ÑÐ¾Ð²Ð½Ñ Ð½Ð° %.0f гоÑÑей%n", peopleCount); } } while (peopleCount <= 1); return (int) peopleCount; } public static void checkBook(){ System.out.println("\nÐобавленнÑе ÑоваÑÑ:\n" + checkBook); } public static float digitCheck(Scanner sc) { float result; while (true) { try { String input = sc.nextLine(); result = Float.parseFloat(input); System.out.println(input); break; } catch (NumberFormatException e) { System.out.println("ÐÑибка пÑи вводе ÑиÑла (вÑÑÑеÑилÑÑ Ñимвол, оÑлиÑнÑй Ð¾Ñ ÑиÑÑÑ), попÑобÑйÑе ввод еÑе Ñаз"); } } return result; } public static void calculator(){ Scanner sc = new Scanner(System.in); String productName; float productCost; int i = 1; while(true){ System.out.println("ÐÐ»Ñ ÐÐÐÐРШÐÐÐЯ ввода ÑоваÑов введиÑе \"ÐавеÑÑиÑÑ\", в пÑоÑивном ÑлÑÑае введиÑе название ÑледÑÑÑего ÑоваÑа"); productName = sc.nextLine(); if (productName.equalsIgnoreCase("ÐавеÑÑиÑÑ")) { break; } checkBook = checkBook + String.format("%d.) %s - ",i,productName); System.out.println("ÐведиÑе ÑÐµÐ½Ñ Ð² ÑоÑмаÑе РУÐÐÐ.ÐÐÐÐÐÐÐ: "); do { productCost = digitCheck(sc); if (productCost < 0){ System.out.println("ÐÑибка пÑи вводе ÑÐµÐ½Ñ ÑоваÑа, вÑÑÑеÑено оÑÑиÑаÑелÑное знаÑение!\nÐовÑоÑиÑе ввод ÑенÑ:"); } } while(productCost < 0); checkBook = checkBook + String.format("%.2f %s\n", productCost, rubli(productCost)); cashOut = cashOut + productCost; System.out.println("Ð¢Ð¾Ð²Ð°Ñ ÑÑпеÑно ÐÐÐÐÐÐÐÐ"); i++; } sc.close(); } public static String rubli(double money){ String rubleName = ""; int intMoney = (int) Math.floor(money); int lastDecimalIntMoney = intMoney % 10; int twoLastDecimalIntMoney = intMoney % 100; if (intMoney > 4 && intMoney < 21 || twoLastDecimalIntMoney > 4 && twoLastDecimalIntMoney < 21) { rubleName = " ÑÑблей"; } else{ switch(lastDecimalIntMoney){ case 1: rubleName = "ÑÑблÑ"; break; case 2: case 3: case 4: rubleName = "ÑÑблÑ"; break; case 5: case 6: case 7: case 8: case 9: case 0: rubleName = "ÑÑблей"; break; } } return rubleName; } } public class Main { public static void main(String[] args) { int peopleCount = Obrabotchiki.peopleCountQuestion(); Obrabotchiki.calculator(); Obrabotchiki.checkBook(); float cashByPeople = Obrabotchiki.cashOut / peopleCount; System.out.println(String.format("СÑмма на каждого из %d гоÑÑей %.2f %s",peopleCount, cashByPeople, Obrabotchiki.rubli(cashByPeople))); } }