Skip to content

Conversation

@AleksandrRegulus
Copy link
Owner

Калькулятор готов

Comment on lines 62 to 64
public static String getPadejOfRubl (double sum) {

double i = Math.floor(sum % 10); // получаем последний символ целой части суммы как число

Choose a reason for hiding this comment

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

⚠ Если сумма на каждого гостя получится, например, 114, то в консоль будет выведено - 114.00 рубля.
Лучше дополнительно учесть, что для чисел в пределах 11-19 - должно быть "рублей". Для этого стоит проверять, что остаток от <число> % 100, находится включительно между 11 и 19

Copy link
Owner Author

Choose a reason for hiding this comment

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

Согласен, не додумал, исправлю

Comment on lines 67 to 69
if (i == 1) { return "рубль"; }
else if (i >= 2 && i <= 4) { return "рубля"; }
else { return "рублей"; }

Choose a reason for hiding this comment

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

🍏 Вместо такого стейтмента из if else-if, можно использовать switch case

Copy link
Owner Author

Choose a reason for hiding this comment

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

Я думал об этом, но не придумал как перечислить диапазон от 2 до 4 в switch case

Choose a reason for hiding this comment

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

Можно так

case 1:
return " рубль.";
case 2:
case 3:
case 4:
return " рубля.";

Вместо else будет default:

Copy link
Owner Author

Choose a reason for hiding this comment

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

Да, я именно так и подумал сделать теперь) Спасибо за подсказку

Comment on lines +3 to +4
public class AdvancedScanner {
Scanner scan = new Scanner(System.in);

Choose a reason for hiding this comment

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

Логика этого класса выглядит, как эффективное и универсальное решение, для обработки введенных значений в консоль. Круто 👍

Copy link
Owner Author

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