Skip to content

ДЗ на проверку - #1

Open
AleksandrRegulus wants to merge 3 commits into
mainfrom
dev
Open

AleksandrRegulus wants to merge 3 commits into
mainfrom
dev

Conversation

@AleksandrRegulus

Copy link
Copy Markdown
Owner

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

Comment thread src/main/java/Main.java Outdated
Comment on lines +62 to +64
public static String getPadejOfRubl (double sum) {

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

Copy link
Copy Markdown

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
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

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

Comment thread src/main/java/Main.java Outdated
Comment on lines +67 to +69
if (i == 1) { return "рубль"; }
else if (i >= 2 && i <= 4) { return "рубля"; }
else { return "рублей"; }

Copy link
Copy Markdown

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
Copy Markdown
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

Copy link
Copy Markdown

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
Copy Markdown
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);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
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.

2 participants