Program to check perfect square in java

Simple Java program to check whether a number is perfect square or not | Java Programming

import java.util.Scanner;

public class checkPerfectSquare{

public static void main(String []args){

Scanner sc = new Scanner(;

System.out.println("Enter a number to check: ");

double num = sc.nextDouble();


double d=Math.sqrt(num);

if (d-Math.floor(d)==0){

System.out.print(num+ " is a perfect square number.");



System.out.print(num+ " is not a perfect square number.");




18 views0 comments

Recent Posts

See All

Calculate BMI in Java | AskTheCode

Write a Java program that reads values for weight in kilograms and height in centimeters and prints out the BMI... interpretation of it...

"Believe you can and you're halfway there"