Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Quadratic {
- public static void main(String[] args)
- {
- int a = 2;
- int b = 20;
- int c = 6;
- double x1 = 0;
- double x2 = 0;
- double D = (b * b) - (4 * a * c);
- if (D > 0) {
- x1 = (int) (-b + Math.sqrt(D)) / (2 * a);
- x2 = (int) (-b - Math.sqrt(D)) / (2 * a);
- System.out.println("x1 = " + x1 + "; x2 = " + x2);
- }
- else if (D == 0) {
- x1 = (int) (-b) / (2 * a);
- System.out.println("x1 = " + x1);
- }
- else if (D < 0) {
- System.out.println("Уравнение не имеет корней! D < 0!");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement