From b3fa0bd486b9caf8040745c8380b5b16a57aa3df Mon Sep 17 00:00:00 2001 From: Alfia17 Date: Mon, 28 Apr 2025 10:39:35 +0400 Subject: [PATCH] =?UTF-8?q?=D0=97=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8=D0=B5=20?= =?UTF-8?q?=E2=84=96=2011=20=D0=B2=D1=8B=D0=BF=D0=BE=D0=BB=D0=BD=D0=B5?= =?UTF-8?q?=D0=BD=D0=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Task11.java | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/Task11.java diff --git a/src/Task11.java b/src/Task11.java new file mode 100644 index 0000000..19d5518 --- /dev/null +++ b/src/Task11.java @@ -0,0 +1,24 @@ +import java.util.Scanner; +public class Main { + public static void main(String[] args) { + System.out.println("Задание №11"); + Scanner scan = new Scanner(System.in); + System.out.println("Введите a - "); + double a = scan.nextDouble(); + System.out.println("Введите b - "); + double b = scan.nextDouble(); + System.out.println("Введите c - "); + double c = scan.nextDouble(); + double dis = b * b - 4 * a * c; + if (dis > 0) { + double x1 = (-b + Math.sqrt(dis)) / (2 * a); + double x2 = (-b - Math.sqrt(dis)) / (2 * a); + System.out.println("Корни квадратного уравнения - x1 - " + x1 + " x2 = " + x2); + } else if (dis == 0) { + double x = -b / (2 * a); + System.out.println("x1 = x2 = " +x); + } else { + System.out.println("Квадратное уравнение не имеет действительных корней"); + } + } +}