Skip to content

Commit 70de58c

Browse files
authored
Update RootsOfQuadraticEqn.java
1 parent 620037c commit 70de58c

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

Basic Codes/RootsOfQuadraticEqn.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//Find the roots of the quadratic Equation
12
import java.util.Scanner;
23

34
public 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+
}

0 commit comments

Comments
 (0)