Basic calculator

import java.util.Scanner ;
public class calculator {

    public static void main(String args[]) {
        takeInput();
    }
	public static void takeInput(){
     Scanner s = new Scanner(System.in);
	 char ch = s.next().charAt(0);
	 if (ch == 'X' || ch == 'x'){
		 return ;
	 }
	 else if (ch == '+'){
		 int a = s.nextInt();
		 int b = s.nextInt();
		 System.out.println(a+b); 
	 }
	 else if (ch == '-'){
		 int a = s.nextInt();
		 int b = s.nextInt();
		 System.out.println(a-b);
	 }
	 else if (ch == '*'){
		 int a = s.nextInt();
		 int b = s.nextInt();
		 System.out.println(a*b);
	 }
	 else if (ch == '/'){
		 int a = s.nextInt();
		 int b = s.nextInt();
		 System.out.println(a/b);
	 }
	 else if (ch == '%'){
		 int a = s.nextInt();
		 int b = s.nextInt();
		 System.out.println(a%b);
	 }
	 else{
		 System.out.println("Invalid operation. Try again.");
		 takeInput();
	 }
	}
}

the code is working fine on eclipse for all the test cases , then why it is showing an error while submitting the code ?

where is ur loop
there are multiple test case in a single case
so please use the loop and switch case for this problem

hope this will help u

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.