Basic Calculator

I am pasting my code here, please let me know why am I getting NoSuchElementException:

import java.util.*;
public class Main {
public static void main(String args[]) {

	Scanner sc = new Scanner(System.in);
	int a=0;
	int b=0;

	while(true){

		char c = sc.next().charAt(0);
		
		if(c=='+' || c=='-' || c=='*' || c=='/' || c=='%' || c=='x' || c=='X'){
		   a = sc.nextInt();
		   b = sc.nextInt();
		}

		if(c=='+') System.out.println(a+b);
		if(c=='-') System.out.println(a-b);
		if(c=='*') System.out.println(a*b);
		if(c=='/') System.out.println(a/b);
		if(c=='%') System.out.println(a%b);
		if(c=='x' || c=='X') break;
		else{
			System.out.println("Invalid operation. Try again.");
		}
	}
}

}

Ok My issue is resolved, I needed to check if there is token for next input or not.