Simple Calculator

On execution my program is showing no such element exception
CODE-
import java.util.;
public class Main {
public static void main(String args[]) {
Scanner scn = new Scanner(System.in);
char n = scn.next().charAt(0);
while(n != β€˜x’||n!=β€˜X’){
int n1 = scn.nextInt();
int n2 = scn.nextInt();
if(n == β€˜+’){
System.out.println(n1+n2);
}else if(n == β€˜-’){
System.out.println(n1-n2);
}else if(n ==’
’){
System.out.println(n1*n2);
}else if(n ==’/’){
System.out.println(n1/n2);
}else if(n ==’%’){
System.out.println(n1%n2);
}else{
System.out.println(β€œInvalid operation. Try again.”);
}
n = scn.next().charAt(0);

	}
}

}

@satwik7142,
Simply Put a loop and take input operator and then take input of two digits and then perform the operation till the user inputs β€˜x’ or β€˜X’.

If n is a non arithmetic symbol in the beginning you directly have to print β€œtry again” instead of taking inputs for n1 and n2.

Only if n is an arithmetic symbol take inputs for n1 and n2.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.