Showing wrong answer for all testcases

Scanner sc =new Scanner(System.in);
int n=sc.nextInt();

        boolean isprime=true;
        for(int i=2;i<=n/2;i++){
            if(n%i==0) {
            	isprime=false;
            
            }
        	
            if(isprime==true){
                System.out.println("Prime");
            }
            else{
                System.out.println("Not Prime");
            }
        }

This if-else block should be outside the ‘for’ loop, you have put it inside

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.