forked from Yandex-Practicum/Java-Module-Project-YP
-
Notifications
You must be signed in to change notification settings - Fork 0
ураааа #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Open
ураааа #2
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
61 changes: 58 additions & 3 deletions
src/main/java/Main.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,61 @@ | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.Scanner; | ||
| public class Main { | ||
| public static void main(String[] args) { | ||
| System.out.println("Hello world!"); | ||
|
|
||
| ArrayList<String> schets = new ArrayList<>(); | ||
| ArrayList<Float> sum = new ArrayList<>(); | ||
| System.out.println("Добро пожаловать в наше заведение! На скольких человек необходимо разделить ваш счёт?"); | ||
| Scanner scanner = new Scanner(System.in); | ||
| int otw = scanner.nextInt(); | ||
| while (otw < 2) { | ||
| System.out.println("Для использования нашего приложения необходимо не менее двух посетителей, пожалуйста, повторите попытку."); | ||
| otw = scanner.nextInt(); | ||
| } | ||
|
|
||
| for (int i = 1; i <= otw; ++i) { | ||
| String naz; | ||
| float sch = 0; | ||
| ArrayList<String> eda = new ArrayList<>(); | ||
| System.out.printf("Пользователь номер %d, укажите название товара, которое вы хотите заказать, и его стоимость на следующей строке.", i); | ||
| naz = scanner.next(); | ||
| while (!(naz.equalsIgnoreCase("Завершить"))) { | ||
| float summ = scanner.nextFloat(); | ||
| sch = summ + sch; | ||
| eda.add(naz); | ||
| System.out.printf("Товар '%s' успешно добавлен в счёт!", naz); | ||
| System.out.printf("Пользователь номер %d, укажите название товара, которое вы хотите заказать, и его стоимость на следующей строке. Если вы больше не хотите ничего заказывать, напишите 'Завершить'.", i); | ||
| naz = scanner.next(); | ||
| } | ||
| schets.add(String.valueOf(eda)); | ||
| sum.add(sch); | ||
| eda.clear(); | ||
| } | ||
|
|
||
| for (int i = 0; i < otw; i++) { | ||
| System.out.printf("Пользователь номер %d, ваши добавленные товары:", i + 1); | ||
| ArrayList<String> s = new ArrayList<>(); | ||
| s.add(schets.get(i)); | ||
|
|
||
| for (String ed : s) { | ||
| System.out.println(ed); | ||
| } | ||
|
|
||
| int okr = (int)Math.floor(sum.get(i)); | ||
| int ost = okr % 10; | ||
| int ostt = okr % 100; | ||
| String str = String.format("%d", okr); | ||
|
|
||
| if (((4 < ost) && (okr <= 20)) || (okr == 11) || ((okr > 110) && (ost == 1))) { | ||
| System.out.printf("Ваша сумма: %.2f рублей\n", sum.get(i)); | ||
| } else if (ost == 0) { | ||
| System.out.printf("Ваша сумма: %.2f рублей\n", sum.get(i)); | ||
| } else if (str.contains("1") && okr <= 101 || ostt == 1){ | ||
| System.out.printf("Ваша сумма: %.2f рубль\n", sum.get(i)); | ||
| } else { | ||
| System.out.printf("Ваша сумма: %.2f рубля\n", sum.get(i)); | ||
| } | ||
| s.clear(); | ||
| } | ||
| } | ||
| } | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.