square root and prime numbers

Hello

It is the first time that I post on this site, so I do not know if it really

good category. I try to write a small java program that determines if a number is

prime or not, it looks like this:

if (nombreEntré % 2 != 0)

System.out.println(nombreEntré +" est un nombre premier"); // prime

else if(nombreEntré % 2 == 0 && nombreEntré != 2)

System.out.println(nombreEntré +" n'est pas un nombre premier"); // not prime

but if I write 51 or 25 (which are not prime number) it said me prime because it is odd. My question is what way should we change the program to detect odd numbers compounds as non-prime?

And I try to express the square root of a number, but Math.sqrt () instead of loop with if ... else or while statement. is there a way?

Sorry for my bad english

Thank you in advance