#### Roots of Quadratic Equation coderinme

Roots of Quadratic Equation coderinme

The quadratic equation is given by:

ax^2 + bx + c = 0

The solution to the quadratic equation is given by the quadratic formula:

Root1 = ( -b + Root(b^2 – 4ac) ) /2a

Root2 = ( -b + Root(b^2 – 4ac) ) /2a

The expression inside the square root is called discriminant and is denoted by Δ:

D = b^2 – 4ac

Write a java program to find the roots of a quadratic equation. Assign the values of a, b and c of the equations in the program itself.

```
import java.io.*;
public class Q1
{
public static void main(String[] args)
{
float a=3,b=5,c=2;
double d1,d2;
System.out.println("The roots of a=3, b=5 & c=2 of the quadratic equation are");
d1=(-b+Math.sqrt(b*b-4*a*c))/(2*a);
d2=(-b-Math.sqrt(b*b-4*a*c))/(2*a);
System.out.println("The first root is: "+d1);
System.out.println("The second root is: "+d2);
}
}
```

For more programs on Java, visit our Java Archives

All rights reserved. No part of this Post may be copied, distributed, or transmitted in any form or by any means, without the prior written permission of the website admin, except in the case of brief quotations embodied in critical reviews and certain other noncommercial uses permitted by copyright law. For permission requests, write to the owner, addressed “Attention: Permissions Coordinator,” to the admin @coderinme