Skip to content

Проектная работа 1 - #1

Open
Natalia-Mmesa wants to merge 2 commits into
mainfrom
dev
Open

Natalia-Mmesa wants to merge 2 commits into
mainfrom
dev

Conversation

@Natalia-Mmesa

Copy link
Copy Markdown
Owner

Проектная работа 1


if ( itog2 %10 ==1){
return "рубль";
} else if (itog2 %10==2 || itog2 %10 == 3 || itog2 %10 ==4) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Лучше записать else if (itog2 % 10 >= 2 && itog2 % 10 <= 4), а также можно один раз высчитать остаток от 10 и присвоить переменной, с которой и работать в проверках, т.е int itog2 = (int) itog1 % 10

Comment on lines +3 to +13
public static String Formater (double itog1){

int itog2 = (int) itog1;

if ( itog2 %10 ==1){
return "рубль";
} else if (itog2 %10==2 || itog2 %10 == 3 || itog2 %10 ==4) {
return "рубля";
} else {
return "рублей";
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠ Если итог будет равен 114, то будет выведено 114,00 рубля

Дополнительно лучше учесть, что для чисел 11-19 - должно быть "рублей". Для этого стоит проверять, что <число> % 100 между 11 и 19 включительно находится

Comment thread src/main/java/Main.java
Comment on lines +25 to +28
} else if (ludi>1){
System.out.println("наконец то, начнем считать!");

break;}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🍏 Можно просто else, без else if (ludi>1). Эффект тот же будет

@@ -0,0 +1,45 @@
import java.util.Scanner;

public class calculator {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🍏 На будущее, лучше именовать классы с большой буквы, т.е. Calculator

import java.util.Scanner;

public class calculator {
public static void Produkti (){

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🍏 А функции именовать с маленькой

sum = sum + cena;
System.out.println("Товар успешно добавлен");

Scanner otvet = new Scanner(System.in);

@ilshat-abdulin ilshat-abdulin Mar 11, 2023 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🍏 В этой функции можно использовать один сканер, который создан ранее - Scanner scanner = new Scanner(System.in);

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