Please tell me what is wrong with this code

import java.util.;
import static java.lang.Math.
;
public class Main {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int b = sc.nextInt();
int c = sc.nextInt();
int d = (bb-4ac);
double val = sqrt(abs(d));
if(d>0)
{
System.out.println(“Real and Distinct”);
System.out.print((double)(-b+val)/(2
a) + (double)(-b-val)/(2*a));
}
if(d==0)
{
System.out.println(“Real and Equal”);
System.out.print(d);
System.out.print(d);
}
if(d<0)
{
System.out.println(“Imaginary”);
}

}

}

hey @Poulomi
use Math.sqrt() instead of sqrt()
also Math.abs instead of abs()
If Real and Distinct , print the roots in increasing order.
if (d == 0) { // print root here
System.out.println(“Real and Equal”);
System.out.print(d+" ");
System.out.print(d);
}
The root is a type of integer. You convert to a double type
Sample Input

1 -11 28

Sample Output

Real and Distinct 4 7

import java.util.; import java.lang.Math; public class Main { public static void main(String args[]) { Scanner sc = new Scanner(System.in); int a = sc.nextInt(); int b = sc.nextInt(); int c = sc.nextInt(); double d = (bb-4ac); double val = Math.sqrt(Math.abs(d)); if(d>0) { System.out.println(“Real and Distinct”); System.out.print((double)(-b+val)/(2a) + (double)(-b-val)/(2a)); } if(d==0) { System.out.println(“Real and Equal”); System.out.print(d+" "); System.out.print(d); } if(d<0) { System.out.println(“Imaginary”); } } }

Please help with this,i have changed the necessary ,but still it is showing “Exception in thread”

if d is 0
then root of Quadratic Equation is -b/(2*a)
correct code

import java.util.*;

import java.lang.Math;

public class Main {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int b = sc.nextInt();
int c = sc.nextInt();
double d = (b * b - 4 * a * c);
double val = Math.sqrt(Math.abs(d));
if (d > 0) {
System.out.println(“Real and Distinct”);
System.out.print((int) ((-b - val) / (2 * a)) +" "+ (int) ((-b + val) / (2 * a)));
}
if (d == 0) {
System.out.println(“Real and Equal”);
System.out.print(-b / (2 * a) + " ");
System.out.print(-b / (2 * a));
}
if (d < 0) {
System.out.println(“Imaginary”);
}
}
}

Exception in thread “main” java.util.NoSuchElementException
at java.util.Scanner.throwFor(Scanner.java:862)
at java.util.Scanner.next(Scanner.java:1485)
at java.util.Scanner.nextInt(Scanner.java:2117)
at java.util.Scanner.nextInt(Scanner.java:2076)
at Main.main(Main.java:8)

This is the error with the modified code

@Poulomi code is fine I have verified
plzz give custom input
or you can submit directly

ok,i tried to give custom inputs but no output is coming,so i am just submitting.

May be technical issues
code is fine
drop Mail [email protected]
Are you getting 100 points ??

No,I tried to give custom inputs ,and again it’s showing that error also I am unable to submit the code.

@Poulomi
send me Screen shot
and resolved all thread except this plzz

!

send with class Name

did already,the second image is with class name

You have a teamviewer on your laptop

No,I don’t please help with some alteration

plzz install teamviewer . give me id and password