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/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/List.java b/src/main/java/List.java new file mode 100644 index 0000000..3f8c792 --- /dev/null +++ b/src/main/java/List.java @@ -0,0 +1,67 @@ +import java.util.Scanner; + +public class List { + static double totalPrice = 0.00f; + static String listProduct = ""; + public static void requestProduct() { + Scanner scanner = new Scanner(System.in); + + while(true) { + + + System.out.println("Введите название товара"); + String name = scanner.next(); + listProduct = listProduct.concat(name + ";\n"); + System.out.println("Введите цену товара"); + double price = checkFailPrice(); + totalPrice += price; + System.out.println("Товар успешно добавлен!\nЕсли хотите добавить еще товар введите любой символ.\nДля завершения создания списка напините \"Завершить\"."); + String result = scanner.next(); + if(result.equalsIgnoreCase("Завершить")){ + break; + } + + } + + + } + public static String whichRub(double num){ + int sum = (int)num; + sum = sum % 100; + if(10 0) { + return trueDouble; + } else { + System.out.println("Ошибка! Введите корректную цену."); + } + } + else { + System.out.println("Ошибка! Введите корректную цену."); + } + } + } +} + diff --git a/src/main/java/Main.java b/src/main/java/Main.java index a9198c4..ec2ddfe 100644 --- a/src/main/java/Main.java +++ b/src/main/java/Main.java @@ -1,8 +1,9 @@ public class Main { public static void main(String[] args) { - // ваш код начнется здесь - // вы не должны ограничиваться только классом Main и можете создавать свои классы по необходимости - System.out.println("Привет Мир"); + System.out.println("Привет!"); + People.howMany(); + List.requestProduct(); + List.makeList(); } } diff --git a/src/main/java/People.java b/src/main/java/People.java new file mode 100644 index 0000000..fef89a0 --- /dev/null +++ b/src/main/java/People.java @@ -0,0 +1,26 @@ +import java.util.Scanner; + +public class People { + + public static int persons; + + public static void howMany(){ + System.out.println("На скольких человек необходимо разделить счёт?"); + while(true) { + Scanner scanner = new Scanner(System.in); + boolean hasInt = scanner.hasNextInt(); + if(hasInt) { + int hasPersons = scanner.nextInt(); + if (hasPersons > 1) { + persons = hasPersons; + return; + } else { + System.out.println("Ошибка! Введите корректное число."); + } + } + else { + System.out.println("Ошибка! Введите корректное число."); + } + } + } +}