import java.util.*;
public class BasicCalculator
{
public static void main(String args[])
{
Scanner sr = new Scanner(System.in);
char ch = sr.nextLine().charAt(0);
int N1, N2;
while(ch!='x' || ch!='X')
{
if(ch == '+'|| ch=='*'|| ch =='%' || ch =='/'|| ch =='-')
{
N1 = sr.nextInt();
N2 = sr.nextInt();
if(N2>0)
{
if(ch == '+')
System.out.println(N1+N2);
if(ch == '-')
System.out.println(N1-N2);
if(ch == '*' )
System.out.println(N1*N2);
if(ch == '%' && N2!=0)
System.out.println(N1%N2);
if(ch == '/' && N2!=0)
System.out.println(N1/N2);
}
}
else
System.out.println("Invalid operation. Try again.");
String st = sr.next();
ch = st.charAt(0);
}
}
}
This code runs just fine in my Eclipse IDE and gives the required output but gives a runtime error NoSuchElementException when submiting.