Computer Science, asked by shreyapandey29, 6 months ago

Wriye a java program to check wether the number is perfect square or not ........Wrong anwer or no anwer will be reported​

Answers

Answered by jiyasounderya
1

Answer:

•Take the square root of the number.

•Take floor/ceil/round of the square root which we got in step 1

•Subtract value we got in step 2 from the square root.

If the output of step 3 is 0 then the number is perfect square else not.

Explanation:

hope this is useful for u

Answered by ronan42
1

Answer:

// Finding whether a number is a perfect square number in Java

import java.io.BufferedReader;

import java.io.IOException;

import java.io.InputStreamReader;

 

public class PerfectSquareNumber {

     

    public static void main(String[] args) throws IOException{

        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

        System.out.print("Please enter an integer : ");

        int number = Integer.parseInt(reader.readLine());

         

        int sqrt = (int) Math.sqrt(number);

        if(sqrt*sqrt == number) {

            System.out.println(number+" is a perfect square number!");

        }else {

            System.out.println(number+" is NOT a perfect square number!");

        }

         

    }

}

Similar questions