
Again the code is not accepting any inputs and the same error is being provided
NoSuchElementException indicates that the element being requested does not exist. always try to check your loops if they are running for more iterations than needed
your input method is wrong
try this:
do {
ch = scn.next().charAt(0); // Use cin in case of c++
if (ch == '+' || ch == '-' || ch == ' * ' || ch == '/' || ch == '%') {
operation(ch);
} else {
if (ch != 'x' && ch != 'X')
System.out.println("Invalid operation. Try again.");
}
} while (ch != 'x' && ch != 'X');