import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int numberOfPersons = 0; String name = ""; double price = 0.0; Product random = new Product(name, price); Calculator calc = new Calculator(random); while (true) { System.out.println("Ðа ÑколÑÐºÐ¸Ñ Ñеловек нÑжно ÑазделиÑÑ ÑÑÑÑ?"); if (scanner.hasNextInt()) { numberOfPersons = scanner.nextInt(); if (numberOfPersons > 1) { break; } else if (numberOfPersons == 1) { System.out.println("ÐÑ Ð¾Ð´Ð¸Ð½, ÑÑÑÑ Ð´ÐµÐ»Ð¸ÑÑ Ð½Ðµ нÑжно)"); } else { System.out.println("ÐекоÑÑекÑное знаÑение"); } } else{ System.out.println("ÐекоÑÑекÑное знаÑение"); scanner.nextLine(); } } System.out.println("ÐведиÑе название пÑодÑкÑа"); scanner.nextLine(); name = scanner.nextLine(); while (true) { System.out.println("ÐведиÑе ÑÑоимоÑÑÑ Ð¿ÑодÑкÑа в ÑоÑмаÑе XX,XX"); if(scanner.hasNextDouble()) { price = scanner.nextDouble(); if(price >= 0) { Product UserInput = new Product(name, price); calc.addProduct(UserInput); System.out.println("ÐÑодÑÐºÑ ÑÑпеÑно добавлен"); System.out.println("Ðе Ñ Ð¾ÑиÑе добавиÑÑ ÐµÑе один пÑодÑкÑ?"); System.out.println("ÐведиÑе название пÑодÑкÑа или"); System.out.println("ÐведиÑе \"ÐавеÑÑиÑÑ\", ÑÑÐ¾Ð±Ñ Ð·Ð°Ð²ÐµÑÑиÑÑ Ð¿ÑоÑеÑÑ Ð´Ð¾Ð±Ð°Ð²Ð»ÐµÐ½Ð¸Ñ ÑоваÑов"); scanner.nextLine(); String answer = scanner.nextLine(); if (answer.equalsIgnoreCase("завеÑÑиÑÑ")) { break; } else { name = answer; } } else{ System.out.println("ÐекоÑÑекÑное знаÑение"); scanner.nextLine(); } } else{ System.out.println("ÐекоÑÑекÑное знаÑение"); scanner.nextLine(); } } calc.everyonePays(numberOfPersons); calc.ending(calc.fullPriceSharing); System.out.println("ÐобавленнÑе ÑоваÑÑ:\n" + calc.listOfProducts); System.out.println(String.format("ÐаждÑй должен заплаÑиÑÑ %.2f" + " %s", calc.fullPriceSharing, calc.rubles)); } }