-
Notifications
You must be signed in to change notification settings - Fork 220
Comments
Conversation
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.
Можно try-catch разместить внутри бесконечного цикла while, тогда при вводе строки пользователю будет позволено снова ввести число, без перезапуска программы (как сделано с числами меньше 1)
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.
Можно вместо 1 < 4 писать просто true
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.
1 != 0 можно заменить на true, а i = i убрать. Может, здесь for можно заменить на цикл while?
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.
Math.floor(j) % 100 повторяется. можно посчитать один раз, записать в переменную и использовать её
Вместо ^ чаще используют написание ||
Можно условие заменить на Math.floor(j) % 100 >= 11 && Math.floor(j) % 100 <= 14
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.
Можно убрать переменную, написав просто return " рублей";, и ниже тоже
Программа больше не падает при некорректном вводе числа человек.
Окончание теперь выводиться правильно.