first commit

This commit is contained in:
2021-04-14 16:00:09 +05:30
commit 430dfcee8b
16 changed files with 574 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
// Program to find the root of quadratic equation (Dynamic Method).
import java.util.Scanner;
public class RootsOfQuadraticEquation {
public static void main(String args[]){
double secondRoot = 0, firstRoot = 0;
Scanner sc = new Scanner(System.in);
System.out.println("Enter the value of a :");
double a = sc.nextDouble();
System.out.println("Enter the value of b :");
double b = sc.nextDouble();
System.out.println("Enter the value of c :");
double c = sc.nextDouble();
double determinant = (b*b)-(4*a*c);
double sqrt = Math.sqrt(determinant);
if(determinant>0){
firstRoot = (-b + sqrt)/(2*a);
secondRoot = (-b - sqrt)/(2*a);
System.out.println("Roots are :: "+ firstRoot +" and "+secondRoot);
}else if(determinant == 0){
System.out.println("Root is :: "+(-b + sqrt)/(2*a));
}
}
}