Repository navigation
Conversation
| import java.util.Scanner; | ||
|
|
||
| public class Calculate { | ||
| static String toComplete = "завершить"; |
| } | ||
|
|
||
| while (price <= 0) { | ||
| if (price <= 0) { |
There was a problem hiding this comment.
В while уже проверяется это условие, if можно убрать
| public String GetRubleAddition(double num) { | ||
| int numToInt = (int) num; | ||
| double preLastDigit = num % 100 / 10; | ||
| if (preLastDigit == 1) { |
There was a problem hiding this comment.
Из-за того, что переменная типа double, это условие сработает только для num = 10. Если бы была int, работало бы для 11-19
| case 4: | ||
| return "Человека"; | ||
| default: | ||
| return "рублей"; |
| System.out.println("некоректное значение для подсчета.Введите колличество человек заного "); | ||
| human = scanner.nextInt(); | ||
| } | ||
| if (human == 1) { |
There was a problem hiding this comment.
Поскольку в while может быть только human <= 1, а human < 1 проверено в верхнем if, тут можно сделать просто else к нему
Author
|
Спасибо за комментарии , все поправлю!
Четверг, 27 октября 2022, 20:38 +04:00 от Tanya Petrukhina ***@***.***>:
***@***.*** commented on this pull request.
----------------------------------------------------------------------
In src/main/java/Calculate.java :
> @@ -0,0 +1,96 @@
+import java.util.ArrayList;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Scanner;
+
+public class Calculate {
+ static String toComplete = "завершить";
static можно убрать
----------------------------------------------------------------------
In src/main/java/Calculate.java :
> + System.out.println("Введите цену товара в формате 'рубли.копейки' [10.45, 11.40] :");
+
+ while (!scanner.hasNextDouble()) {
+ System.out.println("Введите корректное значение :");
+ scanner.next();
+ }
+
+ price = scanner.nextDouble();
+ if (price > 0) {
+ priceList.add(price);
+ sum = sum + price;
+ System.out.println("Товар успешно добавлен! ");
+ }
+
+ while (price <= 0) {
+ if (price <= 0) {
В while уже проверяется это условие, if можно убрать
----------------------------------------------------------------------
In src/main/java/Calculate.java :
> + }
+ }
+ }
+ System.out.println("Если хотите продолжить введите - любой символ,если хотите остановиться введите 'завершить' ");
+ menu = scanner.next();
+ if (menu.equalsIgnoreCase(toComplete)) {
+ break;
+ }
+ }
+ }
+
+
+ public String GetRubleAddition(double num) {
+ int numToInt = (int) num;
+ double preLastDigit = num % 100 / 10;
+ if (preLastDigit == 1) {
Из-за того, что переменная типа double, это условие сработает только для num = 10. Если бы была int, работало бы для 11-19
----------------------------------------------------------------------
In src/main/java/Calculate.java :
> + }
+
+ public String GetHumanAdddition(int num) {
+
+ double preLastDigit = num % 100 / 10;
+ if (preLastDigit == 1) {
+ return "Человек";
+ }
+ switch (num % 10) {
+ case 1:
+ case 2:
+ case 3:
+ case 4:
+ return "Человека";
+ default:
+ return "рублей";
Кажется, тут ошибка)
----------------------------------------------------------------------
In src/main/java/Main.java :
> + Scanner scanner = new Scanner(System.in);
+ System.out.println("На сколько человек нужно разделить счет ?");
+ while (!scanner.hasNextInt()) {
+ System.out.println("Введите корректное значение :");
+ scanner.next();
+ }
+ int human = scanner.nextInt();
+
+
+ while (human <= 1) {
+ if (human < 1) {
+ System.out.println("Колличество человек " + human);
+ System.out.println("некоректное значение для подсчета.Введите колличество человек заного ");
+ human = scanner.nextInt();
+ }
+ if (human == 1) {
Поскольку в while может быть только human <= 1, а human < 1 проверено в верхнем if, тут можно сделать просто else к нему
—
Reply to this email directly, view it on GitHub , or unsubscribe .
You are receiving this because you authored the thread. Message ID: <Yandex-Practicum/Java-Module-Project/pull/96/review/1158643265 @ github . com>
--
Сергей Клушин
Отправлено из Почты Mail.ru
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Моё первое домашнее задание на YandexPracticum.
С уважение Сергей Клушин.