source file name: Quadratic.java

class Quad

{

int a,b,c;

public Quad(int p,int q,int r)

{

a=p;b=q;c=r;

}

public void disproots()

{

System.out.println("coefficents a:"+a+" b: "+b+" c: "+c);

int d=b*b-4*a*c;

if(d>=0)

       {

System.out.println("root are real:");

double r1=(-b+Math.sqrt(d))/(2*a);

double r2=(-b-Math.sqrt(d))/(2*a);

System.out.println("r1="+r1+ " , r2="+r2);

         }

else

System.out.println("root are complex:");

        }

}

class Quadratic

{

public static void main(String as[])

{

Quad q1=new Quad(1,5,6);

q1.disproots();

Quad q2=new Quad(3,2,5);

q2.disproots();

Quad q3=new Quad(3,-12,4);

q3.disproots();

}

}

output:

D:\JavaPrograms\Constructors>javac Quadratic.java

D:\JavaPrograms\Constructors>java Quadratic
coefficents a:1 b: 5 c: 6
root are real:
r1=-2.0 , r2=-2.0
coefficents a:3 b: 2 c: 5
root are complex:
coefficents a:3 b: -12 c: 4
root are real:
r1=2.5 , r2=2.5