Check if given number is perfect square | Java program for the above approach ; If ceil and floor are equal the number is a perfect square ; Driver Code
import java . io . * ; class GFG { static void checkperfectsquare ( int n ) { if ( Math . ceil ( ( double ) Math . sqrt ( n ) ) == Math . floor ( ( double ) Math . sqrt ( n ) ) ) { System . out . print ( " perfect ▁ square " ) ; } else { System . out . print ( " not ▁ a ▁ perfect ▁ square " ) ; } } public static void main ( String [ ] args ) { int n = 49 ; checkperfectsquare ( n ) ; } }