Skip to content

Conversation

@getastep
Copy link
Owner

@getastep getastep commented Feb 3, 2023

No description provided.

int numberOfPeople = 0;
while (numberOfPeople <= 1) {
System.out.println("На скольких человек поделить счет?");
numberOfPeople = scanner.nextInt();

Choose a reason for hiding this comment

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

⚠️ Здесь лучше обработать ошибочный ввод строк вместо чисел. Иначе приложение падает

}
else {
System.out.println("Некорректное значение! Убедитесь, что вводите цифры в формате РУБЛИ,КОПЕЙКИ");
continue;

Choose a reason for hiding this comment

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

🍏 continue здесь не влияет на работу цикла. Можно удалить

Comment on lines +77 to +95
String formatted(double number) {
int x = (int)number;
if (x % 100 / 10 == 1) {
return "рублей";
}
else {
switch (x % 10) {
case 1:
return "рубль";
case 2:
case 3:
case 4:
return "рубля";
default:
return "рублей";
}
}
}
}

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants