-
Notifications
You must be signed in to change notification settings - Fork 222
Pull request к приложению «Калькулятор счёта» #102
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: master
Are you sure you want to change the base?
Conversation
| //Вывод суммы, которую должен заплатить каждый поровну | ||
| if ((money % 100) / 10 == 1){ | ||
| System.out.println("Сумма, которую должен заплатить каждый человек составляет: " + str + " рублей"); | ||
| }else if (money % 100 == 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.
Здесь лучше прописать money % 10 == 1, чтобы попадало 21, 51 и т.д.
| System.out.println("Сумма, которую должен заплатить каждый человек составляет: " + str + " рублей"); | ||
| }else if (money % 100 == 1){ | ||
| System.out.println("Сумма, которую должен заплатить каждый человек составляет: " + str + " рубль"); | ||
| }else if (money % 10 >= 2 && money % 10 <= 4){ |
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.
Выражение money % 10 считается несколько раз, можно посчитать его один раз, записать в переменную и использовать ее
| }else if (money % 10 >= 2 && money % 10 <= 4){ | ||
| System.out.println("Сумма, которую должен заплатить каждый человек составляет: " + str + " рубля"); | ||
| }else { | ||
| System.out.println("Сумма, которую должен заплатить каждый человек составляет: " + str + " рублей"); |
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.
Код System.out.println("Сумма, которую должен заплатить каждый человек составляет: " + str + " рублей"); повторяется в каждой ветке, кроме слова рубль, лучше код вынести после if-else, оставив в нем только определение слова
| } | ||
|
|
||
| }else{ | ||
| System.out.println("Вы ввели некорректное значение. Пожалуйста, введите значение больше 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." записать в константу, он повторяется 3 раза
Добавил обработку на вопрос про количество человек и стоимость с помощью методов scanner.hasNextInt() и hasNextFloat()