Advertisement
Guest User

Untitled

a guest
Nov 20th, 2019
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.91 KB | None | 0 0
  1. package hop_qua;
  2. import java.util.Scanner;
  3.  
  4. public class Hop_Qua {
  5.  
  6.     public static double Nghiem(double a, double b,double c)
  7.     {
  8.         double x1,x2;
  9.         double dt=b*b-4*a*c;
  10.         if(dt<0) return 0;
  11.         else if(dt==0)
  12.         {
  13.             x1=-b/2/a;
  14.             if(x1<0) return 0;
  15.             else return x1;
  16.         }else
  17.         {
  18.             x1=(-b+Math.sqrt(dt))/2/a;
  19.             x2=(-b-Math.sqrt(dt))/2/a;
  20.             if(x1<0||x2<0) return 0;
  21.             else
  22.             {
  23.                 if(x1<x2) return x1;
  24.                 else return x2;
  25.             }
  26.         }
  27.     }
  28.     public static void main(String[] args) {
  29.         Scanner Sc=new Scanner(System.in);
  30.         double x,y;
  31.         x=Sc.nextDouble();
  32.         y=Sc.nextDouble();
  33.         double h=Nghiem(12, -4*(x+y), x*y);
  34.         double v=4*h*h*h-2*(x+y)*h*h+x*y*h;
  35.         System.out.println(""+v);
  36.     }
  37.    
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement