File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ //Find the roots of the quadratic Equation
12import java .util .Scanner ;
23
34public class quadratic_roots {
@@ -20,6 +21,7 @@ public static void main(String[] args) {
2021 // d stands for determinant
2122 double d = (b * b ) - 4 * (a * c );
2223
24+ //if d = 0 roots are equal and real, id d>0 roots are real and distinct
2325 if (d >= 0 ) {
2426 root1 = (-b + Math .sqrt (d )) / (2 * a );
2527 root2 = (-b - Math .sqrt (d )) / (2 * a );
@@ -33,7 +35,7 @@ public static void main(String[] args) {
3335 System .out .println ("Roots are real and distinct" );
3436 }
3537 }
36-
38+ //d<0, roots are imaginary
3739 else {
3840 double real = -b / (2 * a );
3941 double imaginary = Math .sqrt (-d ) / (2 * a );
@@ -42,5 +44,4 @@ public static void main(String[] args) {
4244 System .out .println ("Roots are imaginary!" );
4345 }
4446 }
45-
46- }
47+ }
You can’t perform that action at this time.
0 commit comments