Computer Science, asked by army4335, 8 months ago

How to Find Perfect Square In Java

Answers

Answered by asmaunisa56333
0

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

Answered by mainak087
0

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"); } }

Hope you would like my answer and do follow me on Brainly

Similar questions