Stop taking input after one case.its a calculator problem from assignment

public class calc {

public static void main(String[] args) {
	
	char ch;

do
{
Scanner scn=new Scanner(System.in);
ch=scn.next().charAt(0);
int a=scn.nextInt();
int b=scn.nextInt();

switch(ch)
{
case '+':
	int c=a+b;
	System.out.println(""+c);
	break;
case '-':
	int d=a-b;
	System.out.println(""+d);
	break;
case '*':
	int e=a*b;
	System.out.println(""+e);
	break;
case '/':
	int f=a/b;
	System.out.println(""+f);
	break;
case '%':
	int g=a%b;
	System.out.println(""+g);
	break;
case 'X':
	break;
	
case 'x':
	break;
	
	default:
		System.out.println("Invalid operation.Try again");
		break;
	
}

}

while(ch==‘X’||ch==‘x’);

}

}

Hey nishant, this happen because when you give + as input value of ch becomes ‘+’ and the code perform the add operation and after this loop checks the test condition since ch != ‘X’ and also ch != ‘x’ loop terminates

so i should not use break statement?

See according to question you have to take input a and b inside the switch case and use break statement only when ch ==‘x’ or ch==‘X’.
And use this syntax:
do{
//Code
}while(True)

cant understand sir.

Hi @nkumar199775
The problem with your code is that even when the input is: x
It would wait till user enters two numbers, which is not expected.

Also there is mistake in your default case
It should be
“Invalid operation. Try again.”
instead of
“Invalid operation.Try again”
The format of output needs to be followed very strictly.

You can go through my code to get an idea how you need to proceed in this question.
https://ide.codingblocks.com/s/51209

Try to code it again yourself.