monkeyslut45

Кирилл Деменев

Oct 22nd, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.81 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.  
  5.     public static void main(String[] args)
  6.     {
  7.         double a, b, c, D;
  8.         Scanner in = new Scanner(System.in);
  9.         a = in.nextInt();
  10.         b = in.nextInt();
  11.         c = in.nextInt();
  12.         D = b * b - 4*a*c;
  13.         System.out.println(D);
  14.  
  15.         if (D > 0) {
  16.             double x1, x2;
  17.             x1 = (-b - Math.sqrt(D)) / (2 * a);
  18.             x2 = (-b + Math.sqrt(D)) / (2 * a);
  19.             System.out.println("x1 = " + x1 + ", x2 = " + x2);
  20.         }
  21.         else if (D == 0) {
  22.             double x;
  23.             x = -b / (2 * a);
  24.             System.out.println("x = " + x);
  25.         }
  26.         else {
  27.             System.out.println("Уравнение не имеет корней");
  28.         }
  29.         //я пытался
  30.     }
  31. }
Add Comment
Please, Sign In to add comment