The program is syntactically correct but the desired output for the roots(here r1 and r2) are not correct. Why?
import java.util.Scanner;
public class QuadraticEqua {
public static void main(String[] args) {
Scanner scn = new Scanner(System.in);
int a= scn.nextInt();
int b= scn.nextInt();
int c= scn.nextInt();
int d=b*b-4*a*c;
int r1=(int)(-b+(Math.sqrt(d))/(2*a));
int r2=(int)(-b-(Math.sqrt(d))/(2*a));
if(d>0) {
System.out.println("Real and Distinct");
System.out.println(r1+" "+r2);
}else if(r1==r2){
System.out.println("Real and Equal");
System.out.println(r1+" "+r2);
}else if(d<0) {
System.out.println("Imaginary");
}
}
}