Skip to content

выполненное задание. Примечание: реализовал суммы с копейками вместо … - #1

Open
David-Arcanone wants to merge 2 commits into
mainfrom
dev
Open

David-Arcanone wants to merge 2 commits into
mainfrom
dev

Conversation

@David-Arcanone

Copy link
Copy Markdown
Owner

Примечание: реализовал суммы с копейками вместо дробей. (Если надо могу как в задании просто рубли)

Comment thread src/main/java/Main.java
public class Main {
public static void main(String[] args) {
System.out.println("Hello world!");
Scanner scanner = new Scanner(System.in);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Рекомендация: - Форматирование кода - в Java принят немного другой стиль форматирования кода. Если не вдаваться в детали, то легко и быстро отформатировать код в Android Studio можно следующей комбинацией клавиш: в Windows Ctrl + Alt + L , в MacOs ⌘ + ⌥ + L.

Comment thread src/main/java/Main.java Outdated
scanner.close();
}
}
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.

Некритично, но в java принято один класс- один файл

Comment thread src/main/java/Main.java Outdated
int changeValue=(int)(price*100)-integerPartOfPrice*100; //валюты меньше копейки нет
String currencyPronunciation= " рублей ";
String changePronunciation= " копеек";
switch (integerPartOfPrice){

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Рекомендация: возможно , комбинация с if в этом случае будет удобнее: if(integerPartOfPrice >=1 && integerPartOfPrice<=4)

Comment thread src/main/java/Main.java
case 2:;
case 3:;
case 4: changePronunciation=" копейки";break;
if (((integerPartOfPrice % 10) > 1) && ((integerPartOfPrice % 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.

integerPartOfPrice % 10 -считается несколько раз. Можно вынести в переменную

Comment thread src/main/java/Main.java
while (incorrectInput) {
myLine = sn.nextLine();
try {
myNumber = Double.parseDouble(myLine);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

также удобно использовать hasNexDouble()

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