public class MyCalc { private int persons; public String products = ""; public double total_price = 0; private int total = 0; MyCalc(int persons){ this.persons = persons; } public void addProduct(){ ProductItem item = new ProductItem(); item.askProductData(); System.out.println("Ðобавлен ÑÐ¾Ð²Ð°Ñ " + item.name + " ÑÑоимоÑÑÑÑ "+item.getPrice()); products += item.getNameAndPrice() + "\n"; this.total_price += item.price; this.total++; } public void calculateAndPrint(){ System.out.println("\n"); System.out.println("ÐаказаннÑе ÑоваÑÑ:"); System.out.println(products.trim()); //пÑÐ¾Ð´Ð°Ð²ÐµÑ Ð¸ копейки не пÑоÑÑиÑ, Ñак ÑÑо еÑли поÑÐ¾Ð²Ð½Ñ Ð½Ðµ поделиÑÑÑ Ð±ÑдÑÑ ÑаевÑе double price_per_person = Math.ceil(100*total_price/persons)/100; System.out.println("ÐÑого "+AddFormat.format(total, "ÑоваÑ", "ÑоваÑа","ÑоваÑов", true)+" на ÑÑÐ¼Ð¼Ñ "+AddFormat.rub(total_price)); System.out.println("Ðелим ÑÑÐµÑ Ð½Ð° "+ AddFormat.format(persons, "Ñеловека", "Ñеловек","Ñеловек", true)); System.out.println("ÐаждÑй должен заплаÑиÑÑ Ð¿Ð¾ "+ AddFormat.rub(price_per_person)); } }