Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Comments

Приложение "Калькулятор Счёта" #1

Open
Lyoncheese wants to merge 4 commits intomain from
dev
Open

Приложение "Калькулятор Счёта" #1
Lyoncheese wants to merge 4 commits intomain from
dev

Conversation

@Lyoncheese
Copy link
Owner

@Lyoncheese Lyoncheese commented Jun 6, 2023

Первая версия.

public static double getDouble (Scanner scanner) {
try {
double num = scanner.nextDouble();
return num;
Copy link

@faritowich faritowich Jun 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Можно просто return scanner.nextDouble();

if (rest1 >= 10 && rest1 <= 19) {
System.out.printf("%.2f Рублей", x);
}
else if (rest == 0 || rest >= 5 && rest <= 9) {
Copy link

@faritowich faritowich Jun 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rest <= 9 - лишнее условие, rest >= 5 достаточно, так как при %10 и так будет 9 или меньше)

else if (rest == 1) {
System.out.printf("%.2f Рубль", x);
}
else if (rest >= 2 && rest <= 4) {
Copy link

@faritowich faritowich Jun 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rest <= 4 также лишнее

} else {
System.out.println("Это некорректное значение для подсчёта");
}
}
Copy link

@faritowich faritowich Jun 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Такие отдельные логические блоки, как этот (ввод и обработка количества людей), а также логические блоки с вводом товаров и выводом результатов лучше выносить в отдельные методы и затем вызывать их там, где необходимо. Это позволяет улучшить читаемость кода, т.к. разнородная логика не смешивается в один сплошной код, а также упрощает поддержку кода.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

1 more reviewer

@faritowich faritowich faritowich left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /