Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Comments

первое домашнее задание#96

Open
Bivis63 wants to merge 1 commit intoYandex-Practicum:master from
Bivis63:master
Open

первое домашнее задание #96
Bivis63 wants to merge 1 commit intoYandex-Practicum:master from
Bivis63:master

Conversation

@Bivis63
Copy link

@Bivis63 Bivis63 commented Oct 26, 2022

Моё первое домашнее задание на YandexPracticum.
С уважение Сергей Клушин.

import java.util.Scanner;

public class Calculate {
static String toComplete = "завершить";
Copy link

@MagicUnderHood MagicUnderHood Oct 27, 2022

Choose a reason for hiding this comment

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

static можно убрать

}

while (price <= 0) {
if (price <= 0) {
Copy link

@MagicUnderHood MagicUnderHood Oct 27, 2022

Choose a reason for hiding this comment

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

В while уже проверяется это условие, if можно убрать

public String GetRubleAddition(double num) {
int numToInt = (int) num;
double preLastDigit = num % 100 / 10;
if (preLastDigit == 1) {
Copy link

@MagicUnderHood MagicUnderHood Oct 27, 2022

Choose a reason for hiding this comment

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

Из-за того, что переменная типа double, это условие сработает только для num = 10. Если бы была int, работало бы для 11-19

case 4:
return "Человека";
default:
return "рублей";
Copy link

@MagicUnderHood MagicUnderHood Oct 27, 2022

Choose a reason for hiding this comment

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

Кажется, тут ошибка)

System.out.println("некоректное значение для подсчета.Введите колличество человек заного ");
human = scanner.nextInt();
}
if (human == 1) {
Copy link

@MagicUnderHood MagicUnderHood Oct 27, 2022

Choose a reason for hiding this comment

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

Поскольку в while может быть только human <= 1, а human < 1 проверено в верхнем if, тут можно сделать просто else к нему

Copy link
Author

Bivis63 commented Oct 27, 2022 via email

Спасибо за комментарии , все поправлю!
Четверг, 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

1 more reviewer

@MagicUnderHood MagicUnderHood MagicUnderHood left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /