import java.util.InputMismatchException; import java.util.Scanner; public class Products { static String strProducts = ""; static double sum = 0; static double productPrice; static void productCount() { Scanner scanner = new Scanner(System.in); while (true) { System.out.println("ХоÑиÑе добавиÑÑ ÑоваÑ?"); String productInput = scanner.next(); switch (productInput.toLowerCase()) { case "да": while (true) { System.out.println("ÐведиÑе название ÑоваÑа."); String productName = scanner.next(); strProducts = strProducts.concat("\n").concat(productName); while (true) { System.out.println("ÐведиÑе ÑÑоимоÑÑÑ ÑоваÑа."); try { productPrice = scanner.nextDouble(); }catch (InputMismatchException b){ System.out.println("Ðведено не ÑиÑло."); scanner.nextLine(); } if (productPrice > 0) { break; } else if (productPrice < 0) { System.out.println("СÑоимоÑÑÑ Ð½Ðµ Ð¼Ð¾Ð¶ÐµÑ Ð±ÑÑÑ Ð¾ÑÑиÑаÑелÑной!"); } } System.out.println("Ð¢Ð¾Ð²Ð°Ñ Ð´Ð¾Ð±Ð°Ð²Ð»ÐµÐ½!"); sum = sum + productPrice; System.out.println("ХоÑиÑе добавиÑÑ ÐµÑе ÑоваÑ? (ÐведиÑе \"ÐавеÑÑиÑÑ\" ,ÑÑÐ¾Ð±Ñ Ð·Ð°Ð²ÐµÑÑиÑÑ Ð¿ÑоÑеÑÑ Ð´Ð¾Ð±Ð°Ð²Ð»ÐµÐ½Ð¸Ñ ÑоваÑов.)"); String productInput2 = scanner.next(); switch (productInput2.toLowerCase()) { case "да": break; case "неÑ": return; case "завеÑÑиÑÑ": return; default: while (true) { System.out.println("ÐведиÑе \"Ðа\" ,ÑÑÐ¾Ð±Ñ Ð´Ð¾Ð±Ð°Ð²Ð¸ÑÑ ÑоваÑ.\nÐведиÑе \"ÐавеÑÑиÑÑ\" ,ÑÑÐ¾Ð±Ñ Ð·Ð°Ð²ÐµÑÑиÑÑ Ð¿ÑоÑеÑÑ Ð´Ð¾Ð±Ð°Ð²Ð»ÐµÐ½Ð¸Ñ ÑоваÑов."); String productInput3 = scanner.next(); if (productInput3.equalsIgnoreCase("да")) { break; } else if (productInput3.equalsIgnoreCase("ÐавеÑÑиÑÑ")) { return; } else { } } } } case "неÑ": return; default: System.out.println("ÐведиÑе да или неÑ!"); } } } }