{"action":"opened","issue":{"url":"https://api.github.com/repos/VR-Java/Java/issues/3","labels_url":"https://api.github.com/repos/VR-Java/Java/issues/3/labels{/name}","comments_url":"https://api.github.com/repos/VR-Java/Java/issues/3/comments","events_url":"https://api.github.com/repos/VR-Java/Java/issues/3/events","html_url":"https://github.com/VR-Java/Java/issues/3","id":123544968,"number":3,"title":"квадратне рівняння","user":{"login":"VR-Java","id":16392245,"avatar_url":"https://avatars.githubusercontent.com/u/16392245?v=3","gravatar_id":"","url":"https://api.github.com/users/VR-Java","html_url":"https://github.com/VR-Java","followers_url":"https://api.github.com/users/VR-Java/followers","following_url":"https://api.github.com/users/VR-Java/following{/other_user}","gists_url":"https://api.github.com/users/VR-Java/gists{/gist_id}","starred_url":"https://api.github.com/users/VR-Java/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/VR-Java/subscriptions","organizations_url":"https://api.github.com/users/VR-Java/orgs","repos_url":"https://api.github.com/users/VR-Java/repos","events_url":"https://api.github.com/users/VR-Java/events{/privacy}","received_events_url":"https://api.github.com/users/VR-Java/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-12-22T19:49:29Z","updated_at":"2015-12-22T19:49:29Z","closed_at":null,"body":"//У три змінні a, b і c записані три дійсних числа. \r\n//Створити програму, яка буде знаходити і виводити на екран речові коріння квадратного рівняння Ax2 + Bx + C = 0 \r\n//або повідомляти, що коріння немає\r\n\r\nimport java.util.Scanner;\r\n\r\npublic class Main {\r\n\r\n\tpublic static void main(String[] args) {\r\n\t\t// TODO Auto-generated method stub\r\n\t\tScanner koef = new Scanner(System.in);\r\n\t\t\r\n\t\tSystem.out.print(\"Введіть А:\");\r\n\t\tint a = koef.nextInt();\r\n\t\t\r\n\t\tif (a != 0){ //якщо коефіцієнт А = 0, то рівняння не є квадратним\r\n\t\t\r\n\t\t\tSystem.out.println(\"Введіть B:\");\r\n\t\t\tint b = koef.nextInt();\r\n\t\t\t\r\n\t\t\tSystem.out.println(\"Введіть C:\");\r\n\t\t\tint c = koef.nextInt();\r\n\t\t\t\r\n\r\n\t\t\tSystem.out.println(\"Ваше квадратне рівняння \" + a + \"x2 + \" + b + \"x + \" + c + \" = 0\");\r\n\t\t\tdouble d = Math.sqrt(b*b - 4*a*c); // Дискримінант\r\n\t\t\t\r\n\t\t\tif (d>=0){\r\n\t\t\t\tdouble x1 = (-b + d)/(2*a);\r\n\t\t\t\tdouble x2 = (-b - d)/(2*a);\r\n\t\t\t\tSystem.out.println(\"має такі корені:\");\r\n\t\t\t\tSystem.out.println(\"x1 = \" + x1);\r\n\t\t\t\tSystem.out.println(\"x2 = \" + x2);\r\n\t\t\t\tSystem.out.println(\"Перевірка 1: \" + a*x1*x1 + \" + \" + b*x1 + \" + \" + c + \" = \" + (a*x1*x1 + b*x1 + c));\r\n\t\t\t\tSystem.out.println(\"Перевірка 2: \" + a*x2*x2 + \" + \" + b*x2 + \" + \" + c + \" = \" + (a*x2*x2 + b*x2 + c));\r\n\t\t\t\tSystem.out.println(\"Дискримінант = \" + d);\r\n\t\t\t} else {\r\n\t\t\t\tSystem.out.println(\"не має дійсних коренів\");\r\n\t\t\t}\r\n\t\t} else{\r\n\t\t\tSystem.out.println(\"Коефіцієнт А не може дорівнювати 0\");\r\n\t\t}\r\n\t}\r\n\r\n}\r\n"}}