Computer Science, asked by gudalasandhya682, 2 months ago

write java program that display the roots of a quadratic equation ax2+bx=0

Answers

Answered by priyankabelwal0
0

Answer:

Java program to find the roots of a quadratic equation

Calculate the determinant value (b*b)-(4*a*c).

If determinant is greater than 0 roots are [-b +squareroot(determinant)]/2*a and [-b -squareroot(determinant)]/2*a.

If determinant is equal to 0 root value is (-b+Math.sqrt(d))/(2*a)

Answered by Prakjita
0

Answer:

Write a program in Java to find the roots of a quadratic equation ax2+bx+c=0 with the following specifications:

Explanation:

Data Members — float a,b,c,d (a,b,c are the co-efficients & d is the discriminant), r1 and r2 are the roots of the equation.

Member Methods:

quad(int x,int y,int z) — to initialize a=x, b=y, c=z, d=0

void calculate() — Find d=b2-4ac

If d < 0 then print "Roots not possible" otherwise find and print:

r1 = (-b + √d) / 2a

r2 = (-b - √d) / 2a

Similar questions