REvising Quadratic equation

code i have written :import java.util.;
import java.lang.Math;
public class Main {
public static void main(String args[]) {
Scanner scn=new Scanner(System.in);
float a =scn.nextInt();
float b =scn.nextInt();
float c =scn.nextInt();
float d;
d=b
b-4ac;
if(d==0){
double x=(-b+Math.sqrt(d))/2a;
double y=(-b+Math.sqrt(d))/2
a;
System.out.println(“real and equal”);
System.out.println(x+" "+y);

	}
	if(d>0){
		double x=(-b+Math.sqrt(d))/2*a;
		double y=(-b+Math.sqrt(d))/2*a;
        System.out.println("real and distinct");
		System.out.println(x+" "+y);

	}
    if(d<0){
        System.out.println("imaginary");
    }

}

}
this code passes only one test case.please check the output format if it is correct or not.

Hi,‘r’ ,‘d’ and ‘i’ should be in capital of real and distinct and imaginary respectively and when (d==0) then you have to print only one root and do ‘r’ and ‘e’ in capital of real and equal.

only one test case is getting passed.for input 1 6 and 8 it is showing real and distinct ;-2.0 -4.0 as output.but still two test cases arenot passed

Your roots are in integer form so make the data type of roots as integer and type cast your ans of the expression by solving as int and also one root is (-b-Math.sqrt(d))/2a,you have taken both roots as (-b+(math.sqrt(d)))/2a

Hi Anshuman,
As you are not responding to this thread, I am marking your doubt as Resolved for now. Re-open it if required.
Please mark your doubts as resolved in your course’s “ Ask Doubt ” section, when your doubt is resolved.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.