Output is right but all test are wrong why

import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner scan = new Scanner(System.in);

    char ch = scan.next().charAt(0);
    while(ch == '+' || ch == '-' || ch == '*' || ch == '/' || ch == '%' || ch == ';') {
        
        int c = 0;
        if(ch=='+') {
            int a = scan.nextInt();
            int b = scan.nextInt();
            c=a+b;
            System.out.println(c);
        }
        else if(ch=='-') {
            int a = scan.nextInt();
            int b = scan.nextInt();
            c=a-b;
            System.out.println(c);
        }
        else if(ch=='*') {
            int a = scan.nextInt();
            int b = scan.nextInt();
            c=a*b;
            System.out.println(c);
        }
        else if(ch=='%') {

            int a = scan.nextInt();
            int b = scan.nextInt();
            if(b != 0)
                c=a%b;
            System.out.println(c);
        }
        else if(ch=='/') {
            int a = scan.nextInt();
            int b = scan.nextInt();
            if(b != 0)
                c=a/b;
            System.out.println(c);
        }
        else
            System.out.println("Invalid operation. Try again.");
        ch = scan.next().charAt(0);
            
    }
    
}

}

hey @himanshusingh2389_63aac7fac0c69386 Your code is not printing anything for the input
.
?
/
4
2
*
4
2
x
To cure this you should use do while loop .
This might help

import java.util.Scanner;
public class main{
   static Scanner scn=new Scanner(System.in);
    public static void main(String[] args) {
        char ch;
        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');
    }
    public static void operation(char ch) {
        int a = scn.nextInt(); // Use cin in case of c++
        int b = scn.nextInt(); // Use cin in case of c++
        int res = 0;
        switch (ch) {
        case '+': {
            res = a + b;
            break;
        }
        case '-': {
            res = a - b;
            break;
        }
        case '*': {
            res = a * b;
            break;
        }
        case '/': {
            res = a / b;
            break;
        }
        case '%': {
            res = a % b;
            break;
        }
        }
        System.out.println(res);
    }
}

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.