diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000..26d3352
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,3 @@
+# Default ignored files
+/shelf/
+/workspace.xml
diff --git a/.idea/.name b/.idea/.name
new file mode 100644
index 0000000..962e712
--- /dev/null
+++ b/.idea/.name
@@ -0,0 +1 @@
+Java-Module-Project
\ No newline at end of file
diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml
new file mode 100644
index 0000000..7643783
--- /dev/null
+++ b/.idea/codeStyles/Project.xml
@@ -0,0 +1,123 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ xmlns:android
+
+ ^$
+
+
+
+
+
+
+
+
+ xmlns:.*
+
+ ^$
+
+
+ BY_NAME
+
+
+
+
+
+
+ .*:id
+
+ http://schemas.android.com/apk/res/android
+
+
+
+
+
+
+
+
+ .*:name
+
+ http://schemas.android.com/apk/res/android
+
+
+
+
+
+
+
+
+ name
+
+ ^$
+
+
+
+
+
+
+
+
+ style
+
+ ^$
+
+
+
+
+
+
+
+
+ .*
+
+ ^$
+
+
+ BY_NAME
+
+
+
+
+
+
+ .*
+
+ http://schemas.android.com/apk/res/android
+
+
+ ANDROID_ATTRIBUTE_ORDER
+
+
+
+
+
+
+ .*
+
+ .*
+
+
+ BY_NAME
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml
new file mode 100644
index 0000000..79ee123
--- /dev/null
+++ b/.idea/codeStyles/codeStyleConfig.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/compiler.xml b/.idea/compiler.xml
new file mode 100644
index 0000000..61a9130
--- /dev/null
+++ b/.idea/compiler.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/gradle.xml b/.idea/gradle.xml
new file mode 100644
index 0000000..6cec569
--- /dev/null
+++ b/.idea/gradle.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..5d10be7
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..35eb1dd
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/java/Main.java b/src/main/java/Main.java
index a9198c4..6621799 100644
--- a/src/main/java/Main.java
+++ b/src/main/java/Main.java
@@ -1,8 +1,110 @@
+import java.util.Scanner;
+
public class Main {
public static void main(String[] args) {
// ваш код начнется здесь
+
// вы не должны ограничиваться только классом Main и можете создавать свои классы по необходимости
System.out.println("Привет Мир");
+ Scanner scanner = new Scanner(System.in);
+ //считываем кол-во гостей
+ int visitor = 0;
+ System.out.println ("Введите колличество гостей");
+ while (true) {
+ String str = scanner.next();
+ while (!isNumeric(str)) {
+ System.out.println("Введите колличество гостей");
+ str = scanner.next();
+ }
+ visitor = Integer.parseInt(str);
+ if ((visitor <= 1) | (visitor == 0)) { + System.out.println("Некорректное кол-во гостей"); + System.out.println("Введите колличество гостей"); + } else if (visitor> 1) {
+ break;
+ }
+ }
+ //считываем кол-во товаров
+ boolean enough = true;
+
+ Product list = new Product();
+ Calculate menu_list = new Calculate();
+ while (enough) {
+ System.out.println("Введите название ");
+ list.name = scanner.next();
+ System.out.println("Введите цену");
+ String str = scanner.next();
+ while (!isNumeric(str)) {
+ System.out.println("Введите цену с разделителем \".\" ");
+ str = scanner.next();
+ }
+ list.price = Double.parseDouble(str);
+ menu_list.getAddList(list.name, list.price);
+ menu_list.getListPrice(list.price);
+ System.out.println("Хотите ввести ещё товар?");
+ System.out.println("Eсли вы хотите ввести ещё товар, введите ДА");
+ System.out.println("Eсли вы хотите ввести ещё товар, введите Завершить ");
+ String answer = scanner.next();
+
+ if (answer.equalsIgnoreCase("завершить")) {
+ enough = false;
+ break;
+ }
+ }
+
+ if (!enough){
+ System.out.println("Добавленные товары:");
+ System.out.println(menu_list.receipt);
+ float pay = (float) (menu_list.pay/visitor);
+ String rubString = "";
+ int rub = (int) (pay % 10);
+ int rubTeen = (int) (pay % 100);
+ if ((rub == 0 ) || (rub == 5) || (rub == 6) || (rub == 7 ) || (rub == 8 ) || (rub == 9 ) || ((rubTeen>= 11) && (rubTeen <= 14))){
+ rubString = "рублей";
+ } else if ((rub == 2) || (rub == 4) || (rub == 3) ){
+ rubString = "рубля";
+ } else if (rub == 1) {
+ rubString = "рубль";
+ }
+
+ String message = "Каждый должен заплатить %.2f %s";
+ System.out.println(String.format(message, pay, rubString));
+ }
+ }
+ public static class Calculate{
+ String receipt = "";
+ double pay = 0;
+
+ public void getAddList (String name, double price) {
+ receipt = receipt + String.format("%s %.2f \n",
+ name,
+ price);
+ System.out.println("Товар успешно добавлен");
+ }
+
+ public void getListPrice(double price){
+ pay = pay + price;
+ }
+ }
+
+ public static class Product {
+ String name;
+ double price;
+ }
+
+ public static boolean isNumeric(String string) {
+ double value;
+
+ if(string == null || string.equals("")) {
+ return false;
+ }
+ try {
+ value = Double.parseDouble(string);
+ return true;
+ } catch (NumberFormatException e) {
+
+ }
+ return false;
}
}