-
Notifications
You must be signed in to change notification settings - Fork 0
Pull request #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Pull request #1
Conversation
| double numRound = Math.floor(number); | ||
| double leftOver= Math.floor(numRound)%10; | ||
| if(leftOver==1){ | ||
| return "рубль"; | ||
| } | ||
| else if (leftOver>=2&&leftOver<=4){ | ||
| return "рубля"; | ||
| } | ||
| else if (leftOver>=5&&leftOver<=9){ | ||
| return "рублей"; | ||
| }else{ | ||
| return "рублей"; | ||
| } | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
⚠ Обрати внимание, что если значение будет равным 114, то на выходе получится 114 рубля. То есть, в таком случае, нужно учитывать диапазон чисел 11-19 - "рублей" - для этого стоит проверять, что (114 % 100) между 11 и 19 включительно находится.
| static void check(){ | ||
| System.out.println("Добавленные товары: "+goodsList); | ||
| System.out.println("ОБщая сумма: "+priceTotal+" "+Convert.ending(priceTotal)); | ||
| if (priceTotal ==0&&goodsList.equals("")){System.out.println("Вы не выбрали товар");}//1111 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
А вот это полезное сообщение. Не все об этом заботятся) 👍
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🍏 Лучше не оставлять пустые строки, лишние комментарии для компактности
| double numRound = Math.floor(number); | ||
| double leftOver= Math.floor(numRound)%10; | ||
| if(Math.floor(numRound)%100>=11&&Math.floor(numRound)%100<=19){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🍏 Можно же один раз округлить (и в идеале привести к целочисленному типу) int numRound = (int) Math.floor(number)
Затем уже использовать в проверках
if(numRound %100>=11&&numRound %100<=19)
| } | ||
| else{ | ||
| if(leftOver==1){ | ||
| return "рубль"; | ||
| } | ||
| else if (leftOver>=2&&leftOver<=4){ | ||
| return "рубля"; | ||
| } | ||
| else if (leftOver>=5&&leftOver<=9){ | ||
| return "рублей"; | ||
| }else{ | ||
| return "рублей"; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🍏 Можно использовать автоформатирование, чтобы должным образом выровнять отступы
Комбинации клавиш:
Windows: Ctrl + Alt + L
Linux: Ctrl + Shift + Alt + L
macOS: Option + Command + L
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Спасибо. Это полезно для меня будет.
Тестовое Задание на курсе Яндекс.Практикум.