Java compilation error

Whenver I submit a code in java i get this error on compiling though when i submit it gets accepted

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:6)

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)-(4ac);
double x1,x2;
double a1,b1;
if(d>0)
{

		x1=(Math.sqrt(d)-b)/(2*a);
		x2=(-Math.sqrt(d)-b)/(2*a);
		if(x1>x2) {
			a1=x1;
			b1=x2;
		}
		else {
			a1=x2;
			b1=x1;
		}
		System.out.println("Real and Distinct");
		System.out.println((int)b1+" "+(int)a1);
		
		
		
		
		
	}
	else if(d==0)
	{
		a1=(-b)/(2*a);
		b1=a1;
		System.out.println("Real and Equal");
		System.out.println((int)b1+" "+(int)a1);
	}
	else {
		System.out.println("Imaginary");
	}

}

}

@prasadnitesh202
When using Scanner class for input, check if the Scanner object sc hasNextInt() and/or hasNext() or not for int and string inputs lets say, before just trying to take the input.
And this will resolve the error.
Example -
For string input :

if(sc.hasNext())
{
String s = sc.next();
}
And for integer input :

if(sc.hasNextInt())
{
int n = sc.nextInt();
}