Skip to content

Первое практическое задание - #74

Open
smitford wants to merge 4 commits into
Yandex-Practicum:masterfrom
smitford:master
Open

smitford wants to merge 4 commits into
Yandex-Practicum:masterfrom
smitford:master

Conversation

@smitford

Copy link
Copy Markdown

Использовал английский язык в выводе, надеюсь это не критично.

Comment thread src/main/java/Main.java
// ваш код начнется здесь
// вы не должны ограничиваться только классом Main и можете создавать свои классы по необходимости
System.out.println("Привет Мир");
int count=0;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

По умолчанию int инициализируется 0, так что здесь инициализировать не обязательно

Comment thread src/main/java/Main.java
count = countOfPeople();
System.out.println (count);
Scanner scanner = new Scanner(System.in);
boolean trigger = true;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Это инициализированное значение не используется (в while будет проверяться то, что будет получено от !chek.equalsIgnoreCase("complete");), так что можно не инициализировать

Comment thread src/main/java/Main.java Outdated
if (bill <2 && bill>=1){
System.out.println(String.format(finalPhrase1, bill));
} else{
System.out.println(String.format(finalPhrase2, bill));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Строка System.out.println(String.format(<окончание слова рубль>, bill)); повторяется, лучше её вынести за пределы if-else, а в нем оставить только определение окончания, записать в переменную и использовать после оператора

Comment thread src/main/java/Main.java
String finalPhrase1 = "%.2f рубль";
String finalPhrase2 = "%.2f рубля";
String finalPhrase3 = "%.2f рублей";
int ostatok = (int) (Math.floor(bill)%10.0);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Хорошо, что используешь переменные для подсчета только 1 раз
Вместо 10.0 можно использовать просто 10

Comment thread src/main/java/Main.java
if (ostatok == 1) {
System.out.println(String.format(finalPhrase1, bill));
} else{
System.out.println(String.format(finalPhrase2, bill));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Код System.out.println(String.format(finalPhrase2, bill)); повторяется несколько раз, лучше его вынести за if-else, а в нем определять только в переменной, каким будет слово рубль

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants