public class Calculator { short participantsQuantity; String products = ""; float cost = 0; public Calculator(short participantsQuantity) { this.participantsQuantity = participantsQuantity; } public void addProduct(String productName, float cost) { this.cost = this.cost + cost; String productRepresentation = productName + " : " + CurrencyFormatter.getCostRepresentation(cost); products = products.isEmpty() ? productRepresentation : products + "\n" + productRepresentation; System.out.println("Ð¢Ð¾Ð²Ð°Ñ ÑÑпеÑно добавлен"); } public void calculate() { if (this.participantsQuantity < 1) { System.out.println("ÐолиÑеÑÑво ÑÑаÑÑников не Ð¼Ð¾Ð¶ÐµÑ Ð±ÑÑÑ Ð¼ÐµÐ½ÑÑе 1"); return; } if (products.isEmpty()) { System.out.println("ТоваÑÑ Ð¾ÑÑÑÑÑÑвÑÑÑ!"); return; } float result = this.cost / this.participantsQuantity; System.out.println( //ÐопÑавил, Ñделал пÑавда ÑеÑез ÑоÑмаÑ. String.format("ÐолиÑеÑÑво ÑÑаÑÑников: %d \nÐобавленнÑе ÑоваÑÑ: \n%s \n-> ÐÑого Ñ Ñеловека: %s", this.participantsQuantity, this.products, CurrencyFormatter.getCostRepresentation(result))); } }