How to Find Perfect Square In Java
Answers
Answer:
the answer is explained as follows:
Explanation:
to find the perfect square in java is we take the square root of the number and convert to integer and multiply the integer with itself.
hope this helps you
follow me on brainly
Answer:
import java.util.Scanner;
class JavaExample {
static boolean checkPerfectSquare(double x)
{
double sq = Math.sqrt(x);
return ((sq - Math.floor(sq)) == 0);
}
public static void main(String[ ] args)
{
System.out.print("Enter any number:");
Scanner scanner = new Scanner(System.in);
double num = scanner.nextDouble();
scanner.close();
if (checkPerfectSquare(num))
System.out.print(num+ " is a perfect square number");
else
System.out.print(num+ " is not a perfect square number"); } }