Repository navigation
Приложение "Калькулятор Счёта" - #1
Open
Lyoncheese wants to merge 4 commits into
Open
Lyoncheese wants to merge 4 commits into
Lyoncheese wants to merge 4 commits into
Conversation
faritowich
reviewed
Jun 6, 2023
| public static double getDouble (Scanner scanner) { | ||
| try { | ||
| double num = scanner.nextDouble(); | ||
| return num; |
There was a problem hiding this comment.
Можно просто return scanner.nextDouble();
| if (rest1 >= 10 && rest1 <= 19) { | ||
| System.out.printf("%.2f Рублей", x); | ||
| } | ||
| else if (rest == 0 || rest >= 5 && rest <= 9) { |
There was a problem hiding this comment.
rest <= 9 - лишнее условие, rest >= 5 достаточно, так как при %10 и так будет 9 или меньше)
| else if (rest == 1) { | ||
| System.out.printf("%.2f Рубль", x); | ||
| } | ||
| else if (rest >= 2 && rest <= 4) { |
| } else { | ||
| System.out.println("Это некорректное значение для подсчёта"); | ||
| } | ||
| } |
There was a problem hiding this comment.
Такие отдельные логические блоки, как этот (ввод и обработка количества людей), а также логические блоки с вводом товаров и выводом результатов лучше выносить в отдельные методы и затем вызывать их там, где необходимо. Это позволяет улучшить читаемость кода, т.к. разнородная логика не смешивается в один сплошной код, а также упрощает поддержку кода.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Первая версия.