English, asked by Anonymous, 9 months ago

Solve this java program it's easy
Correct answer will be marked as brainliest

don't spam❌
spamming ki to bahut bura anjam hoga​

Attachments:

Answers

Answered by Anonymous
3

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));

     }

  }

}

Similar questions