Repository navigation
выполненное задание. Примечание: реализовал суммы с копейками вместо … - #1
David-Arcanone wants to merge 2 commits into
Conversation
| public class Main { | ||
| public static void main(String[] args) { | ||
| System.out.println("Hello world!"); | ||
| Scanner scanner = new Scanner(System.in); |
There was a problem hiding this comment.
Рекомендация: - Форматирование кода - в Java принят немного другой стиль форматирования кода. Если не вдаваться в детали, то легко и быстро отформатировать код в Android Studio можно следующей комбинацией клавиш: в Windows Ctrl + Alt + L , в MacOs ⌘ + ⌥ + L.
| scanner.close(); | ||
| } | ||
| } | ||
| class Calculator{ |
There was a problem hiding this comment.
Некритично, но в java принято один класс- один файл
| int changeValue=(int)(price*100)-integerPartOfPrice*100; //валюты меньше копейки нет | ||
| String currencyPronunciation= " рублей "; | ||
| String changePronunciation= " копеек"; | ||
| switch (integerPartOfPrice){ |
There was a problem hiding this comment.
Рекомендация: возможно , комбинация с if в этом случае будет удобнее: if(integerPartOfPrice >=1 && integerPartOfPrice<=4)
| case 2:; | ||
| case 3:; | ||
| case 4: changePronunciation=" копейки";break; | ||
| if (((integerPartOfPrice % 10) > 1) && ((integerPartOfPrice % 10) <= 4)) { |
There was a problem hiding this comment.
integerPartOfPrice % 10 -считается несколько раз. Можно вынести в переменную
| while (incorrectInput) { | ||
| myLine = sn.nextLine(); | ||
| try { | ||
| myNumber = Double.parseDouble(myLine); |
There was a problem hiding this comment.
также удобно использовать hasNexDouble()
Примечание: реализовал суммы с копейками вместо дробей. (Если надо могу как в задании просто рубли)