import static java.lang.Math.floor; public class Calculator { int peronCount; double sum = 0; String items = ""; Calculator(int peronCount){ this.peronCount = peronCount; } void addItem(Item item) { sum += item.price; items += item.name + "\n"; } void showResult(){ System.out.println("ÐобавленнÑе ÑоваÑÑ:"); System.out.println(items); double priceForPerson = sum/peronCount; String endOfString = " ÑÑблей"; if((int)floor(priceForPerson) % 100 / 10 != 1) { switch ((int) floor(priceForPerson) % 10) { case 1: endOfString = " ÑÑблÑ"; break; case 2: case 3: case 4: endOfString = " ÑÑблÑ"; break; } } System.out.println("ÐаждÑй Ñеловек должен заплаÑиÑÑ " + String.format("%.2f", priceForPerson) + endOfString); } }